修改Tabhost样式和字体大小的方法

来源:互联网 发布:1688一键传淘宝怎么弄 编辑:程序博客网 时间:2024/04/29 23:40
     tabWidget = tabHost.getTabWidget();        tabHost.addTab(tabHost.newTabSpec("PLAN").setContent(R.id.LinearLayout001)          .setIndicator("计划中"));        tabHost.addTab(tabHost.newTabSpec("COMPLTED").setContent(R.id.LinearLayout003)          .setIndicator("已完成"));       //注意这个就是改变Tabhost默认样式的地方,一定将这部分代码放在上面这段代码的下面,不然样式改变不了        for (int i =0; i < tabWidget.getChildCount(); i++) {  
//修改Tabhost高度和宽度 tabWidget.getChildAt(i).getLayoutParams().height
= 30; tabWidget.getChildAt(i).getLayoutParams().width = 65;
//修改显示字体大小 TextView tv
= (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title); tv.setTextSize(15); tv.setTextColor(this.getResources().getColorStateList(android.R.color.white)); }