`

androdi tab

 
阅读更多
如何改变Android tab 的高度和字体大小
复制代码

1 int count = tabWidget.getChildCount();//TabHost中有一个getTabWidget()的方法
2   for (int i = 0; i < count; i++) {
3    View view = tabWidget.getChildTabViewAt(i);  
4    view.getLayoutParams().height = 80; //tabWidget.getChildAt(i)
5    final TextView tv = (TextView) view.findViewById(android.R.id.title);
6    tv.setTextSize(28);
7    tv.setTextColor(this.getResources().getColorStateList(
8      android.R.color.white));
9   }
10
11 //解释二************************************************************************
12 int width =45;
13 int height =48;
14 for(int i = 0; i < tabWidget.getChildCount(); i++)
15 {
16 //设置高度、宽度,不过宽度由于设置为fill_parent,在此对它没效果
17 tabWidget.getChildAt(i).getLayoutParams().height = height;
18 tabWidget.getChildAt(i).getLayoutParams().width = width;
19 /**
20 * 下面是设置Tab的背景,可以是颜色,背景图片等
21 */
22 View v = tabWidget.getChildAt(i);
23 if (tabHost.getCurrentTab() == i) {
24 v.setBackgroundColor(Color.GREEN);
25 //在这里最好自己设置一个图片作为背景更好
26 //v.setBackgroundDrawable(getResources().getDrawable(R.drawable.chat));
27 } else {
28 v.setBackgroundColor(Color.GRAY);
29 }
30 }

复制代码
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics