android TabHost 修改底部条颜色

来源:互联网 发布:mac怎么调系统字体大小 编辑:程序博客网 时间:2024/05/21 15:47
/**     * 更新Tab标签的颜色,和字体的颜色     *     * @param tabHost     */    private void updateTab(final TabHost tabHost) {        for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {            TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);            tv.setTextSize(16);            tv.setTypeface(Typeface.SERIF, 0); // 设置字体和风格            if (tabHost.getCurrentTab() == i) {                //选中                tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).getBackground().setColorFilter(Color.rgb(52, 147, 232), PorterDuff.Mode.SRC_IN);                tv.setTextColor(this.getResources().getColorStateList(R.color.color_blue));            } else {                //不选中                tv.setTextColor(this.getResources().getColorStateList(R.color.color_grey_3));            }        }    }
0 0
原创粉丝点击