Android:在 HTC Sense 上无法读取 TabWidget 的突出显示选项卡 [英] Android: Highlighted tab of TabWidget not readable on HTC Sense

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

问题描述

在我的 Android 应用中,我使用了一个没有任何特殊定制的 TabWidget.我希望 Android 能够处理特定的外观,例如,如果您将 Android 1.6 与 2.1 进行比较,则效果很好.仅使用 TabWidget 相同的代码会导致不同形式的选项卡,因为 SDK 定义了如何绘制它.例如,它在 2.1 上的外观如下:

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.

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

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...

我的问题是:

1) 为什么 Android 会创建一个白底白字的 TabWidget?文本颜色和背景颜色我都没有定义,所以系统应该选择合理的颜色.

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) 我认为其他 TabWidgets 在 HTC Sense 上看起来还不错,否则这将是一个相当大且受欢迎的问题.那么为什么我的 TabWidget 有这个问题而不是其他问题.

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) 如何在不改变非 Sense 设备外观的情况下解决此问题?

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

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

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"
            >

因此,除了将黑色定义为应用程序的一般背景色之外,没有定义颜色或样式.唯一的例外可能是我对 TabHost 和 TabWidget 使用了标准的 Android id.

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.

/以下是 onCreate 方法中选项卡的定义:

/ 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));

该类扩展了一个 TabActivity.

The class extends a TabActivity.

/编辑 2:出现白底白字的设备是运行 Android 2.1 btw 的 HTC Legend.

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

/编辑 3:Dream3r 是对的.将 targetSdk 值更改为 4 也对我有用(之前,它被设置为 6)!我真的不明白,但我现在可以忍受.:)

/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:

推荐答案

您的 AndroidManifest.xml 中是否设置了 android:targetSdkVersion?

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

我使用示例应用程序进行了一些测试,如果我将 targetSdkVersion 设置为大于 4 的值,我会遇到同样的问题.

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

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

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