如何改变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 } 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM