首页 > 其他 > 详细

HorizontalScrollView里的标签改变颜色(今日头条里的功能仿照)

时间:2016-03-21 09:16:36      阅读:281      评论:0      收藏:0      [点我收藏+]

private void selectTab(int position) {
// TODO Auto-generated method stub

for (int i = 0; i < hori_lin.getChildCount(); i++) {
TextView childAt = (TextView) hori_lin.getChildAt(position);
// 字体的长度;
int k = childAt.getMeasuredWidth();
// 从字体到屏幕左边的距离;
int l = childAt.getLeft();

int s = l + k / 2 - mscreenwidth / 2;
horizontalScrollView.smoothScrollTo(s, 0);

TextView child = (TextView) hori_lin.getChildAt(i);
if (position == i) {

child.setTextColor(Color.RED);

} else {
child.setTextColor(Color.BLACK);
}

}

}

HorizontalScrollView里的标签改变颜色(今日头条里的功能仿照)

原文:http://www.cnblogs.com/zhengyanyan/p/5300516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!