public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
System.out.println("position:"+position+",positionOffset:"+positionOffset+",positionOffsetPixels:"+positionOffsetPixels);
LinearLayout.LayoutParams lp = (LayoutParams) iv_tabLine.getLayoutParams();
/*if(currerPagerIndex == 0 && position == 0 ){ // 0->1
lp.leftMargin = (int) (sCreen1_3 * positionOffset + currerPagerIndex * sCreen1_3);
}else if(currerPagerIndex == 1 && position == 0 ){ //1->0
lp.leftMargin = (int) (currerPagerIndex * sCreen1_3 + sCreen1_3 * (1-positionOffset));
}else if(currerPagerIndex == 1 && position == 1){ //1->2
lp.leftMargin = (int) (currerPagerIndex * sCreen1_3 + sCreen1_3 * positionOffset);
}else if(currerPagerIndex == 2 && position == 1){ //2->1
lp.leftMargin = (int) (currerPagerIndex * sCreen1_3 + sCreen1_3 * (1-positionOffset));
}*/
lp.leftMargin = (int) (sCreen1_3 * position + sCreen1_3 * positionOffset);
iv_tabLine.setLayoutParams(lp);
}
老師,可以這樣寫嗎?運行結果一樣,不知這樣常不常用。
2017-04-05
源碼有嗎
2014-09-28
很不錯,一個功能一般都有很多種實現方法,不一定就完全和老師的一樣,通過老師的講解有了自己的實現方法或者更優的實現方法那就最好了