Hello. There are three tabs:

<TabHost android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tabHost"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:background="#008cd8" android:layout_height="wrap_content"></TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/artist_tab" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> </LinearLayout> <LinearLayout android:id="@+id/album_tab" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> </LinearLayout> <LinearLayout android:id="@+id/song_tab" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/listView" /> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost> 

It looks like this: enter image description here

How can I change the color of the highlighted tab? Now if you look at it blue, I want to change it to another one that would be more readable!

    1 answer 1

    In order to change the color will have to create a new graphics with the desired color. Next, install it.

    1. Create 2 xml files

    left_strip.xml

     <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_left"/> <item android:state_focused="false" android:drawable="@drawable/tab_selected_bar_left"/> <item android:state_focused="true" android:drawable="@drawable/tab_focus_bar_left"/> 

    right_strip.xml

     <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_right"/> <item android:state_focused="false" android:drawable="@drawable/tab_selected_bar_right"/> <item android:state_focused="true" android:drawable="@drawable/tab_focus_bar_right"/> </selector> 
    1. In code in TabWidget call 2 methods setLeftStripDrawable and setRightStripDrawable or in xml android:tabStripLeft and android:tabStripRight

    I recommend to look towards PagerTabStrip