我覺得這么做太麻煩,用動畫做很簡單的:
在onPageSelected(int position)中添加下面幾句代碼就可以實現滑動效果了
int w = mTabline.getWidth();//獲取控件的寬度
Animation anim = new TranslateAnimation(currentIndex * w,
position * w, 0, 0);//創建動畫
anim.setDuration(500);
anim.setFillAfter(true);
// 執行動畫
mTabline.startAnimation(anim);
// 設置當前選中頁的索引
currentIndex = position;
2014-10-19
這樣的話,mTabline沒有辦法跟隨手指拖動時一起移動。