I am trying to create a tab that looks like this. But so far this does not work. Can someone help me with this.
http://www.technobuzz.net/wp-content/uploads/2010/02/seesmic-android-260-208.png
The style displays only the colors when selected. When I use the white icon, the text (text pointer) is white. This also applies to the gray icon.
When the icon color is white, the text from setindicator is also white. How can I fix this.
Thanks in advance!
Main.java
intent = new Intent().setClass(this, Settings.class);
spec = tabHost.newTabSpec("settings").setIndicator("Settings",
res.getDrawable(R.drawable.tab_settings))
.setContent(intent);
tabHost.addTab(spec);
TabWidget tw = getTabWidget();
for (int i = 0; i < tw.getChildCount(); i++) {
View v = tw.getChildAt(i);
v.setBackgroundDrawable(getResources().getDrawable
(R.drawable.custom_tab));
}
tab_settings
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/artists_on"
android:color="#bfbfbf"
/>
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/artists_of"
/>
<item
android:state_selected="true"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/artists_of"
/>
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/artists_on"
/>
custom_tab.xml style tabs ...
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#ea9d32"
android:endColor="#ffcc50"
android:angle="270" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:endColor="#ffcc50"
android:startColor="#ffcc50"
android:angle="270" />
</shape>
</item>
<item android:state_focused="false" >
<shape>
<gradient
android:endColor="#ffffff"
android:startColor="#AAAAAA"
android:angle="270" />
<stroke
android:width="1px"
android:color="#000000" />
</shape>
</item>
</selector>
source
share