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

     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)); }

你可能感兴趣的:(修改Tabhost样式和字体大小的方法)