Android - Where to set the color of pressed,focused... Tabs?
I created a small Tab-Layout.
Now how can i specify the color of the TabWidget depending on it开发者_运维知识库s state (focused,pressed..)
I built a new .xml, but i dont know how to set it to my Tabs:
<?xml version="1.0" encoding="UTF-8"?>
<selector
android:id="@+id/tabSelector"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="true"
android:background="#32CD32"/> <br />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"/>
<item
android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"/>
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"/>
</selector>
ok your selector must be into your res/drawable folder
this is the way to set your selector to the first tab ( getChildAt(0) )
tabs = getTabHost();
...
...
...
tabs.getTabWidget().getChildAt(0).setBackgroundColor(R.drawable.my_selector);
精彩评论