我正在使用SlidingTabLayout的自定义视图。我为文本的颜色设置了一个drawable(选择器),但由于某种原因,它只在tab按下时更改而不是select。
<TextView
android:id="@+id/tabText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:textColor="@drawable/tab_text_color_selector"
android:textSize="16sp"
android:paddingLeft="4dp"
android:paddingRight="4dp"/>
drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/white" />
<item android:state_selected="true" android:color="@color/white" />
<item android:state_focused="true" android:color="@color/white" />
<item android:color="@color/blue" />
</selector>
答案 0 :(得分:0)
试试这个。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:color="@color/white" />
<item android:state_active="true" android:color="@color/white" />
<item android:state_pressed="true" android:color="@color/white" />
<item android:state_selected="true" android:color="@color/white" />
<item android:state_focused="true" android:color="@color/white" />
<item android:color="@color/blue" />
</selector>
希望。它会帮助你