can the color orange in selected tab be change into other color

225 Views Asked by At

i have a tab in my project and i'm just wondering if you can change the orange color when you click a tab into other color you desire.i want to change it into other color can you change it through xml only or programmatically ?

xml code is like this:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>

selector:

<!--  Active tab -->
<item android:state_selected="true" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />
<!--  Inactive tab -->
<item android:state_selected="false" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />

1

There are 1 best solutions below

2
Georgi Stoyanov On

Here is some code taken from a different answer that should work:

View mIndicator = inflater.inflate(R.layout.tab_indicator_holo, 
                            mTabHost.getTabWidget(), false); // this will inflate a layout, you can use whatever layout you want
TextView title1 = (TextView) mIndicator.findViewById(android.R.id.title); //so we add a title 

title1.setText("TAB1"); // we bind the title

mTabsAdapter.addTab(mTabHost.newTabSpec("TAB1").setIndicator( mIndicator), F_GetGames.class, null); // we bind the inflated layout

Source