Skip to content Skip to sidebar Skip to footer

Android How To Highlight Drawable Of Selected Action Bar Tab

I am looking to add action bar tabs with icons. I have achieved the following. In this, how do I make the selected tab icon orange i.e. if the first tab is selected, the first ic

Solution 1:

Possible solution is. You must create an icon in white and orange and put it in your drawables folder and in the onCreate method of your currently tab add this here:

//TabActivity.onCreate()
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;

intent = newIntent().setClass(this,YourClass.class);
spec = tabHost.newTabSpec("tab_name").setIndicator("Tab Text", getResources().getDrawable(R.drawable.ic_tab_dialer)).setContent(intent);
tabHost.addTab(spec);

Then, you need to add ic_tab_dialer.xml to res/drawable/ directory with this content:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_selected="true"android:state_pressed="false"android:drawable="@drawable/ic_tab_selected_dialer" /><itemandroid:drawable="@drawable/ic_tab_unselected_dialer" /></selector>

I hope this helps.

Post a Comment for "Android How To Highlight Drawable Of Selected Action Bar Tab"