通常只有一个标签选择器:它是否被选中。我需要添加一个属性,根据片段的内容在某些标签上添加一个小标记。对于标签我使用SmartTabLayout库。
任何想法,如果有可能,如何?我可以使用什么方法在标签文本及其背景下面添加标记?
答案 0 :(得分:0)
使用标签指示
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
<!-- Pressed -->
<item android:state_pressed="true" android:drawable="@drawable/tab_press" />
</selector>
并检查
android:state_pressed="true"