Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 工具栏“选定”选项卡“文本颜色”_Java_Android_Android Tablayout - Fatal编程技术网

Java 工具栏“选定”选项卡“文本颜色”

Java 工具栏“选定”选项卡“文本颜色”,java,android,android-tablayout,Java,Android,Android Tablayout,我正试图在我的一个android应用程序中为标签文本设置自定义颜色,但却将其设置更改为白色。其他选项卡文本将发生更改,但不会仅更改选定选项卡的文本 我的标签样式如下所示 <style name="MineCustomTabText" parent="TextAppearance.Design.Tab"> <item name="tabSelectedTextColor">#000</item> <item na

我正试图在我的一个android应用程序中为标签文本设置自定义颜色,但却将其设置更改为白色。其他选项卡文本将发生更改,但不会仅更改选定选项卡的文本

我的标签样式如下所示

<style name="MineCustomTabText"
        parent="TextAppearance.Design.Tab">
       <item name="tabSelectedTextColor">#000</item>
       <item name="android:textColor">@color/TextColorLite</item>
        <item name="android:textSize">@dimen/textPageCount</item>
    </style>
<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            app:tabGravity="fill"
            app:tabTextAppearance="@style/MineCustomTabText"
            app:tabMode="fixed"
            android:layout_height="wrap_content" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"
        android:color="@color/text_tab_selected" />
    <item
        android:state_selected="false"
        android:color="@color/text_tab_unselected" />
</selector>

#000
@彩色/文本彩色
@dimen/textPageCount
我在布局中使用它,XML如下所示

<style name="MineCustomTabText"
        parent="TextAppearance.Design.Tab">
       <item name="tabSelectedTextColor">#000</item>
       <item name="android:textColor">@color/TextColorLite</item>
        <item name="android:textSize">@dimen/textPageCount</item>
    </style>
<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            app:tabGravity="fill"
            app:tabTextAppearance="@style/MineCustomTabText"
            app:tabMode="fixed"
            android:layout_height="wrap_content" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"
        android:color="@color/text_tab_selected" />
    <item
        android:state_selected="false"
        android:color="@color/text_tab_unselected" />
</selector>


您可以看到我在样式中为所选选项卡设置了黑色,但它只显示白色。让我知道我错过了什么。谢谢

请尝试以下代码:

将此样式添加到您的
表格布局中

<android.support.design.widget.TabLayout
  style="@style/MyCustomTabLayout"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

我希望这将帮助您

尝试以下代码:

将此样式添加到您的
表格布局中

<android.support.design.widget.TabLayout
  style="@style/MyCustomTabLayout"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

我希望这将帮助您

在如下可绘制文件夹中添加
tab\u text\u color.xml

<style name="MineCustomTabText"
        parent="TextAppearance.Design.Tab">
       <item name="tabSelectedTextColor">#000</item>
       <item name="android:textColor">@color/TextColorLite</item>
        <item name="android:textSize">@dimen/textPageCount</item>
    </style>
<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            app:tabGravity="fill"
            app:tabTextAppearance="@style/MineCustomTabText"
            app:tabMode="fixed"
            android:layout_height="wrap_content" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"
        android:color="@color/text_tab_selected" />
    <item
        android:state_selected="false"
        android:color="@color/text_tab_unselected" />
</selector>

然后在style.xml中执行此操作并检查

<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
    <item name="android:textColor">@drawable/tab_text_color</item>
    ...
</style>

@可绘制/制表符\文本\颜色
...

在可绘图文件夹中添加
选项卡\u text\u color.xml
,如下所示

<style name="MineCustomTabText"
        parent="TextAppearance.Design.Tab">
       <item name="tabSelectedTextColor">#000</item>
       <item name="android:textColor">@color/TextColorLite</item>
        <item name="android:textSize">@dimen/textPageCount</item>
    </style>
<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            app:tabGravity="fill"
            app:tabTextAppearance="@style/MineCustomTabText"
            app:tabMode="fixed"
            android:layout_height="wrap_content" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"
        android:color="@color/text_tab_selected" />
    <item
        android:state_selected="false"
        android:color="@color/text_tab_unselected" />
</selector>

然后在style.xml中执行此操作并检查

<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
    <item name="android:textColor">@drawable/tab_text_color</item>
    ...
</style>

@可绘制/制表符\文本\颜色
...

@Priya在您的表格布局中添加如下样式:
style=“@style/MineCustomTabText”
。@Priya在表格布局中添加如下样式:
style=“@style/MineCustomTabText”