android - 对话框中的TextView样式,在froyo中看不到文本,但在ics中可以看到

标签 android

我创建了一个对话框来在 android 中显示消息。它基本上在 ScrollView 中包含一个 TextView ,如下所示

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">



        <TextView 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/about_msg" 
            android:text="@string/about_msg"
            android:autoLink="web"
            android:padding="10dip"
            style="@style/DialogTextSmall" />

</ScrollView>

如您所见,我已将样式应用于 TextView,样式如下所示

<style name="DialogTextSmall">
    <item name="android:textSize">@dimen/text_size_small</item>        
</style>

应用主题设置是这样的

    <style name="AppTheme"  parent="android:Theme.Light">    

问题:

在 ICS api-15 上,它在 TextView 的白色背景上显示精细的黑色文本。

问题是当我在 Froyo 中显示对话框时,即使它似乎占用了空间,文本似乎也没有显示 - 我的猜测是文本的颜色与背景相同(灰黑色)

我知道我可以通过硬编码黑色背景和白色文本来快速修复,但是是否不可能为 TextView 的文本颜色和背景显示平台的默认颜色,而无需我对它们进行硬编码?

最佳答案

您可以继承父样式,然后仅更改您想要更改的值。尝试将您的 XML 更改为:

<style name="DialogTextSmall" parent="@android:style/Widget.TextView>
    <item name="android:textSize">@dimen/text_size_small</item>        
</style>

您可以继承的样式列表可以在Github上的AOSP源中找到here .

EIDT:

默认情况下, TextView 具有黑色文本和透明背景,因此如果 TextView 后面的背景(同样是透明的)是黑色,则需要设置其中之一。

关于android - 对话框中的TextView样式,在froyo中看不到文本,但在ics中可以看到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13853298/

相关文章:

android - glide 强制加载缓存图像,不关心什么分辨率

android - 提取包含添加到数据库表中的经度和纬度的最新行

android - 使用 Android 模拟器和浏览器放大时页面上的元素(即 a、div、h1)移动

android - Ionic - 禁用导航栏的动画

java - 自定义枚举属性给出错误 String types not allowed

android - Activity 泄露了 IntentReceiver android.widget.ViewFlipper

android - 我的 Android 设备无法使用 tns 预览扫描 CLI 中生成的二维码

Javascript setTimeout 在 Android Samsung S4 上被阻止

android - 如何将微调器中的文本放入文件?

android - 有没有比 Html.fromHtml() 更快的方法将 html 字符解码为字符串?