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 } 

 

posted on 2012-04-28 02:04  elleniou  阅读(9492)  评论(0编辑  收藏  举报