可以使用TabHost中的getTabWidget()方法
int count = tabWidget.getChildCount();//TabHost中有一个getTabWidget()的方法
for (int i = 0; i < count; i++) {
View view = tabWidget.getChildTabViewAt(i);
view.getLayoutParams().height = 80; //tabWidget.getChildAt(i)
final TextView tv = (TextView) view.findViewById(android.R.id.title);
tv.setTextSize(12);//设置字体大小
// tv.setTextColor(Color.RED);//设置成红色
tv.setTextColor(this.getResources().getColorStateList( android.R.color.white)); }
解释:tv.setTextSize(12);是可以设置字体大小,但是为了代码的稳定性,不可以直接写数字,要使用带单位的来设置,我在项目中就遇到了这个问题,解决方法是:tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp
int count = tabWidget.getChildCount();//TabHost中有一个getTabWidget()的方法
for (int i = 0; i < count; i++) {
View view = tabWidget.getChildTabViewAt(i);
view.getLayoutParams().height = 80; //tabWidget.getChildAt(i)
final TextView tv = (TextView) view.findViewById(android.R.id.title);
//tv.setTextSize(12);//设置字体大小
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);
//tv.setTextColor(Color.RED);//设置成红色
tv.setTextColor(this.getResources().getColorStateList(
android.R.color.white));
}