Android - Where to set the color of pressed,focused... Tabs? -


I have created a small tab-layout

Now how do I press my position (focus, .. )

I have created a new .xml, but I do not know how to set it on my tab:

  & lt ;; XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Selector Android: id = "@ + ID / Tab selector" xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Item android: state_focused = "false" Android: state_selected = "false" android: state_pressed = "true" android: background = "# 32CD32" /> & Lt; Br / & gt; & Lt; Item android: state_focused = "false" Android: state_selected = "true" android: state_pressed = "false" /> & Lt; Item android: state_focused = "true" Android: state_selected = "false" android: state_pressed = "false" /> & Lt; Item android: state_focused = "true" Android: state_selected = "true" android: state_pressed = "false" /> & Lt; / Selector & gt;  

OK that your selector should be in your res / drawable folder

This is the way to set your selector on the first tab (getChildAt (0))

  tab = getTabHost (); ... ... ... tabs.getTabWidget (). GetChildAt (0) .setBackgroundColor (R.drawable.my_selector);  

Comments