在此图中,在选项卡布局中,选定的选项卡栏下划线颜色为紫色,并且文本。
我搜索未选择的标签栏,但找不到未选择的标签栏下划线。
我想在选择某个选项卡时更改颜色,更改未选择的选项卡下划线颜色。
如果你知道这件事,你会帮助我吗?
在drawable文件夹中创建一个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>
并将这个可绘制对象设置在您的tabLayout
<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:tabBackground="@drawable/custom_indicator" />
要更改未选定的选项卡文本颜色,只需提供默认选项卡文本颜色和选定的选项卡文本颜色,如下所示:
<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/custom_indicator" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)