Android TabWidget in the light of the topic

I have an application designed for frame 1.5 and using a standard lighting theme. When using a tab widget with this theme, tab images are barely visible, and tab captions are completely impossible to distinguish, except for the currently active tab.

In the dark theme by default, these tabs go quite clearly, but this is not a solution with which I would be very pleased. Is there a simple setting that I can set that sets a tab widget for better visibility in light themes, or do I have to manually manipulate images and text styles?

+6
android themes tabwidget
source share
4 answers

it is not very, but you can try it in your activity on the tab.

// light theme support final TabHost tabHost = getTabHost(); tabHost.setBackgroundColor(Color.WHITE); tabHost.getTabWidget().setBackgroundColor(Color.BLACK); // hack to set font size LinearLayout ll = (LinearLayout) tabHost.getChildAt(0); TabWidget tw = (TabWidget) ll.getChildAt(0); // first tab RelativeLayout rllf = (RelativeLayout) tw.getChildAt(0); lf = (TextView) rllf.getChildAt(1); lf.setTextSize(21); lf.setPadding(0, 0, 0, 6); // second tab RelativeLayout rlrf = (RelativeLayout) tw.getChildAt(1); rf = (TextView) rlrf.getChildAt(1); rf.setTextSize(21); rf.setPadding(0, 0, 0, 6); 

/res/values/colors.xml should have

 <resources> <drawable name="black">#ff000000</drawable> <drawable name="white">#ffffffff</drawable> </resources> 

AndroidManiest.xml must have

 <application android:theme="@android:style/Theme.Light"> 

if you want to do something more crazy try http://ezmobile.wordpress.com/2009/02/02/customized-android-tabs/

+10
source share

This is mistake; can you report this in problem tracking ?

AFAIK, your workaround for setting text and image styles sounds right.

It should also be noted that the tab widget in version 2.0 does not look like a light style.

+2
source share

Using the hierarchyviewer tool, I found the android id for the text field in the tab. The best way to change text properties (including color) is as follows:

 TabWidget tw = (TabWidget)tabHost.findViewById(android.R.id.tabs); View tabView = tw.getChildTabViewAt(0); TextView tv = (TextView)tabView.findViewById(android.R.id.title); tv.setTextSize(20); 
+2
source share

A very simple way to solve the color / contrast problem in a layout:

 <TabWidget android:id="@android:id/tabs" android:background="#FF000000" android:padding="2dp" 

This sets the TabWidget background to black and adds a bit of indentation, so you can contrast the tabs with a black background. This is not perfect, but it works in 1.5, 2.2, a light and dark theme.

+2
source share

All Articles