Reputation: 1
In my tabactivity, I display icon that I get from the database, by creating an ImageView and passsing this to the setIndicator method. I have only one image for each tab, so I was wondering if there is way to just change the color of the image alone (as opposed to changing the tab's color) when a tab is selected? Also is it possible to hide the gray line that is being drawn at the bottom of the tabs when a tab is selected? Any help is appreciated..thanks
Upvotes: 0
Views: 6551
Reputation: 1009
Hiding gray line:
yourTabWidget.setStripEnabled(false);
Setting custom image per tab state:
tabitemicon.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/orange"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/white" />
</selector>
Java code:
tabHost = getTabHost():
tabHost.newTabSpec("test").setIndicator("My Tab Title",
res.getDrawable(R.drawable.tabitemicon))
.setContent(someIntent);
Upvotes: 3