views:

257

answers:

2

In my Android app I use a TabWidget without any special customization. I'd like Android to take care of the specific appearance, which works fine if you compare Android 1.6 with 2.1 for example. By just using a TabWidget the same code leads to different forms of tabs because the SDK defines how to draw it. Here is how it looks on 2.1 for example:

alt text

So, the highlighted tab is gray and the font is white and you can read it quite well.

But, if you have HTC Sense, it looks like this: alt text

The picture isn't that good, but just believe me that it's white text on white background which is not really that easy to read...

My questions are:

1) Why does Android create a TabWidget with white on white text? I never defined either the text color or the background color, so the system is supposed to chose sensible colors.

2) I assume that other TabWidgets look just fine on HTC Sense, because otherwise it would be quite a big and popular problem. So why is my TabWidget having this problem and not others.

3) How can I fix this problem without changing the appearance on non Sense devices?

As I said I did not customize the TabWidget in any way. Here is my definition:

<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"
    android:background="@android:color/black"
    >
    <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"
            android:padding="0dp"
            >
      <ScrollView 
            android:id="@+id/shortenerScrollView"
            android:layout_height="fill_parent" 
            android:layout_width="fill_parent"
            android:background="@android:color/black"
            android:fadingEdge="horizontal"
            >

So, besides defining black as my general background color of the app, there's no color or style defintion made. The only exception might be that I'm using standard Android ids for TabHost and TabWidget.

/Edit: Here's the defintion of the tabs in the onCreate method:

th = getTabHost();
th.addTab(th.newTabSpec("shortener").setIndicator(getString(R.string.tabShortenerName),
        res.getDrawable(R.drawable.url_zip)).setContent(R.id.shortenerScrollView));

The class extends a TabActivity.

/Edit 2: The device that comes up with the white on white text is a HTC Legend running Android 2.1 btw.

/Edit 3: dream3r was right. Changing the targetSdk value to 4 did the trick for me, too (before, it was set to 6)! I don't really get it, but I can live with that for now. :)

Here's a picture of how it looks now: alt text

+2  A: 

Do you have android:targetSdkVersion set in your AndroidManifest.xml?

I made some test using sample application and I have the same issue if I set 'targetSdkVersion' to value grater than 4.

dream3r
Yeah, I do! I have set the target to 6 and the minSdk to 3. I will check why exactly I set such a high target, maybe it's not necessary anymore (there have been classes that I specifically used if the user was on a higher SDK, but maybe I don't need it anymore). Thanks for pointing this out, I will give it a try.
Manuel
Nice, works for me! :)
Manuel
A: 

Anyone have a solution that means I don't have to choose between it looking like crap on HTC devices, or not providing Install To SD feature for Froyo users?

MarkG
You're not really posting an answer, but I'm gonna answer it anyway... ;) It works just like dream3r said. For example, set your targetSdkVersion to 4 and your minSdkVersion to 3, set installLocation to auto. This way it should work on all devices and look good.
Manuel