切换时指示器跟随滚动
咱老师想复杂啦,下面是我的测试代码:
public void onPageScrolled(int position, float positionOffSet, int positionOffSetPx) {
int marginLeft = (int) (position * separateWidth + positionOffSet * separateWidth);
Log.i(tag,"margin left: " + marginLeft);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) iv_separate.getLayoutParams();
layoutParams.leftMargin = marginLeft;
iv_separate.setLayoutParams(layoutParams);
}