Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.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
Android TabLayout | TabIndicator未选择的颜色_Android_Android Tablayout - Fatal编程技术网

Android TabLayout | TabIndicator未选择的颜色

Android TabLayout | TabIndicator未选择的颜色,android,android-tablayout,Android,Android Tablayout,我正在使用TabLayout 我需要设置TabIndicator未选中时的颜色 这就是我需要做的- 这就是我所做的- 为此使用应用程序:tabTextColor 当未选中时将显示app:tabTextColor 选择时将显示app:tabSelectedTextColor 使用以下代码: <android.support.design.widget.TabLayout android:id="@+id/tabs" app:tabGravity="fill" a

我正在使用
TabLayout

我需要设置TabIndicator未选中时的颜色

这就是我需要做的-

这就是我所做的-


为此使用
应用程序:tabTextColor

  • 未选中时将显示
    app:tabTextColor

  • 选择将显示
    app:tabSelectedTextColor

使用以下代码:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabGravity="fill"
    app:tabMode="fixed"
    android:background="@color/colorPrimary"
    app:tabIndicatorColor="@color/white"
    app:tabIndicatorHeight="4dp"
    app:tabSelectedTextColor="@color/white"
    app:tabTextColor="#AAAAAA"
    app:tabTextAppearance="@style/NavigationTabTextAppeareance"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="4dp"
    >

如果未选择tab,则可以使用tabtextColor作为默认颜色进行设置

在drawable underlinedrawable.xml中创建xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <!-- UNSELECTED TAB STATE -->
<item android:state_selected="false" android:state_pressed="false">
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- Bottom indicator color for the UNSELECTED tab state -->
        <item android:top="-5dp" android:left="-5dp" android:right="-5dp">
            <shape android:shape="rectangle">
                <stroke android:color="#65acee" android:width="2dp"/>
            </shape>
        </item>
    </layer-list>
</item>
</selector>

要更改选项卡TextColor Underline,请在主xml中添加UnderlinedRavable

<android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabTextColor="@color/unselected_color"
            app:tabSelectedTextColor="@color/selected_color"
            app:tabBackground="@drawable/underlinedrawable" />


未选中线条时,我需要更改线条颜色。@ShoebSiddique查看编辑和可能的重复@尝试了此代码,但它不起作用。@VishvaDave是的,我知道下次会记住:)未选中线条时,我需要更改线条颜色。查看此@ShoebSiddique确定让我检查一下。。。
<android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabTextColor="@color/unselected_color"
            app:tabSelectedTextColor="@color/selected_color"
            app:tabBackground="@drawable/underlinedrawable" />