0

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" />

Giant
  • 1,619
  • 7
  • 33
  • 67
  • you to change the select tab color am right. – Yugesh Feb 07 '14 at 10:42
  • set selector to into u r tab layout – M D Feb 07 '14 at 10:44
  • yes in my example the current tab color is gray the other tab is black and when i click the other tab the orange color appears i want to change it into other color i have a selector i will post it its not working – Giant Feb 07 '14 at 10:45

1 Answers1

0

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

Community
  • 1
  • 1
Georgi Stoyanov
  • 171
  • 1
  • 2
  • 6