Android:TabWidget的突出显示标签在HTC Sense上不可读 [英] Android: Highlighted tab of TabWidget not readable on HTC Sense

查看:178
本文介绍了Android:TabWidget的突出显示标签在HTC Sense上不可读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Android应用程式中,我使用TabWidget没有任何特殊的自定义。我想让Android来处理具体的外观,如果你比较Android 1.6与2.1例如,这很好。通过使用TabWidget,同样的代码会导致不同形式的选项卡,因为SDK定义了如何绘制它。
下面是它在2.1上的样子,例如:





所以,突出显示的标签是灰色的,字体是白色的,你可以读得很好。



但是,如果你有HTC Sense,它看起来像这样:



图片不太好,但相信我是白色背景上的白色文字,这不是很容易阅读...



我的问题是:



1)为什么Android用白色文本创建一个TabWidget?我从来没有定义文本颜色或背景颜色,所以系统应该选择合理的颜色。



2)我假设其他TabWidgets看起来很好的HTC Sense ,因为否则会是一个相当大和流行的问题。所以为什么我的TabWidget有这个问题,而不是其他人。



3)如何解决这个问题,而不改变非Sense设备的外观?



正如我所说,我没有以任何方式自定义TabWidget。这是我的定义:

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

因此,除了定义黑色作为我的应用程序的一般背景颜色,没有颜色或风格定义。唯一的例外情况是我为TabHost和TabWidget使用标准的Android ID。



/ Edit:
这里是onCreate方法:

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

类扩展了TabActivity。



/编辑2:
白色文本上出现的设备是运行Android 2.1 btw的HTC Legend。



/ Edit 3:
dream3r是对的。将targetSdk值更改为4对我来说也是这样(之前,它设置为6)!我真的不能得到它,但我现在可以生活。 :)



下面是它现在的样子:

android:targetSdkVersion c>



我使用示例应用程序做了一些测试,我有同样的问题如果我将 targetSdkVersion 设置为大于 4 的值。


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:

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:

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:

解决方案

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 greater than 4.

这篇关于Android:TabWidget的突出显示标签在HTC Sense上不可读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆