/**
* Scroll自动滚动
* 在ViewPager监听中调用
*
*/
private void autoScroll(int position){
select_tv_item=position;
//自动滚动
for (int i = 0; i < ll_main.getChildCount(); i++) {
TextView tv=(TextView) ll_main.getChildAt(position);
//得到TextView的原始宽度
int tv_measuredWidth = tv.getMeasuredWidth();
//TextView的左边缘像素
int left = tv.getLeft();
//计算要滚到的位置
int scroll_position=left+tv_measuredWidth/2-scrollWidth/2;
hsv.smoothScrollTo(scroll_position, 0);
// View childAt = ll_main.getChildAt(i);
if(i==position){
tv.setSelected(true);
}else{
tv.setSelected(false);
}
}
}
Scroll自动滚动
最新推荐文章于 2024-07-01 16:38:53 发布