Android:Tabstyle

Android:Tabstyle,android,xml,colors,tabs,tabwidget,Android,Xml,Colors,Tabs,Tabwidget,我一直在尝试做一个这样的标签样式。但到目前为止它还不起作用 有人能帮我吗 选定时,样式仅显示颜色。当我使用白色图标时,文本(文本设置指示器)为白色。这也适用于灰色图标 当图标颜色为白色时,setindicator中的文本也为白色。。我怎样才能解决这个问题 提前谢谢 Main.java intent = new Intent().setClass(this, Settings.class); spec = tabHost.newTabSpec("settings").setIn

我一直在尝试做一个这样的标签样式。但到目前为止它还不起作用 有人能帮我吗

选定时,样式仅显示颜色。当我使用白色图标时,文本(文本设置指示器)为白色。这也适用于灰色图标

当图标颜色为白色时,setindicator中的文本也为白色。。我怎样才能解决这个问题

提前谢谢

Main.java

intent = new Intent().setClass(this, Settings.class);
         spec = tabHost.newTabSpec("settings").setIndicator("Settings",
                res.getDrawable(R.drawable.tab_settings))
                .setContent(intent);
                tabHost.addTab(spec);


                TabWidget tw = getTabWidget(); 
                for (int i = 0; i < tw.getChildCount(); i++) { 
                        View v = tw.getChildAt(i); 
                        v.setBackgroundDrawable(getResources().getDrawable 
                        (R.drawable.custom_tab)); 
                } 
intent=newintent().setClass(这是Settings.class);
spec=tabHost.newTabSpec(“设置”).setIndicator(“设置”,
res.getDrawable(R.drawable.tab_设置))
.setContent(意图);
tabHost.addTab(spec);
TabWidget tw=getTabWidget();
对于(int i=0;i
选项卡设置

  <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- PRESSED TAB -->
    <item 
        android:state_pressed="true"
        android:drawable="@drawable/artists_on"
        android:color="#bfbfbf"
        />
    <!-- INACTIVE TABS -->
    <item 
        android:state_selected="false"
        android:state_focused="false"
        android:state_pressed="false"
        android:drawable="@drawable/artists_of"
        />
    <!-- ACTIVE TAB -->
    <item 
        android:state_selected="true"
        android:state_focused="false"
        android:state_pressed="false"
        android:drawable="@drawable/artists_of"
        />
    <!-- SELECTED TAB -->
    <item 
        android:state_focused="true"
        android:state_selected="true"
        android:state_pressed="false"
        android:drawable="@drawable/artists_on"
        />

custom_tab.xml选项卡样式…

<item android:state_pressed="true" >
    <shape>
        <gradient
            android:startColor="#ea9d32"
            android:endColor="#ffcc50"
            android:angle="270" />
    </shape>
</item>

<!-- WHEN SELECTED --> <!-- HOW CAN I SAID WHEN NOT SELECTED? --> 
    <item android:state_focused="true" >
        <shape>
            <gradient
                android:endColor="#ffcc50"
                android:startColor="#ffcc50"
                android:angle="270" />
        </shape>
    </item>

       <item android:state_focused="false" >
        <shape>
            <gradient
                android:endColor="#ffffff"
                android:startColor="#AAAAAA"
                android:angle="270" />
            <stroke
                android:width="1px"
                android:color="#000000" />
        </shape>
    </item>
</selector>

选项卡的背景有四种状态-几乎所有状态都有:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item <!-- PRESSED TAB -->
        android:state_pressed="true"
        android:drawable="@drawable/minitab_pressed"
        />
    <item <!-- INACTIVE TABS -->
        android:state_selected="false"
        android:state_focused="false"
        android:state_pressed="false"
        android:drawable="@drawable/minitab_unselected"
        />
    <item <!-- ACTIVE TAB -->
        android:state_selected="true"
        android:state_focused="false"
        android:state_pressed="false"
        android:drawable="@drawable/minitab_default"
        />
    <item <!-- SELECTED TAB -->
        android:state_focused="true"
        android:state_selected="true"
        android:state_pressed="false"
        android:drawable="@drawable/minitab_selected"
        />
</selector>

粘贴您尝试过的内容。。。。这样我们就可以看到出了什么问题。在选项卡设置XML中,“艺术家”绘图需要位于活动选项卡选择器(列表中的第三个)中,所有其他部分都应该是“艺术家”。现在,只有当选项卡处于选中状态且未处于活动状态时,才能显示“艺术家在线”可绘图。谢谢!!。。因此,我创建了一个(图像)选项卡为选定的,未选定的和默认的。。。我在想我可以改变我的背景?但这不可能是我想要的,我想。。?如何在代码中指定textColor选择器。。非常感谢!可以为图标、背景和文本设置选择器。我现在还不知道如何通过编程来分配textColor,所以我会给你回复的。同时,我建议看一下foursquare应用程序及其源代码:是的,没问题,我会整理一个小项目,明天发布。@JoshClemm我应该在哪里创建选择器颜色文件?我需要包括选项卡选择器吗?
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true" android:color="@color/white" />
    <item android:state_focused="true" android:color="@color/white" />
    <item android:state_pressed="true" android:color="@color/white" />
    <item android:color="#bfbfbf" />
</selector>