【发布时间】:2016-06-28 21:41:06
【问题描述】:
我有一个 android 应用程序,我在 styles.xml 的主题中设置了如下文本和背景颜色:
<style name="MyAppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#28abe3</item>
<item name="colorPrimaryDark">#0f92ca</item>
<item name="colorAccent">#0f92ca</item>
<item name="android:textColor">#8a000000</item>
<item name="android:textColorPrimary">#de000000</item>
<item name="android:colorBackground">#fffafafa</item>
<item name="android:textColorSecondary">#8a000000</item>
<item name="android:textColorTertiary">#8a000000</item>
</style>
这在我能找到的所有测试设备上都非常有效。但是,我有一些用户在三星 Galaxy Tab 4 上运行该应用程序,他们报告说某些文本视图以非常浅的灰色阴影显示文本,与背景几乎无法区分,而不是通过指定的非常深的灰色主题。这不会影响应用程序中的每个 TextView,但下面显示了一个示例:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Here"
android:id="@+id/problematicTextView"
android:layout_weight="1"
android:minHeight="25dp"
style="@android:style/TextAppearance.DeviceDefault.Medium" />
除了购买 Galaxy Tab 4 来通过反复试验进行调试之外,我已经尝试了所有我能想到的方法,但无济于事。以正确的深灰色文本显示的 TextView 与以非常浅灰色显示的文本视图之间的唯一区别是以下行:
style="@android:style/TextAppearance.DeviceDefault.Medium"
正常工作的有:
style="@android:style/TextAppearance.DeviceDefault.Small"
但据我了解,这只是为了影响文本大小而不是颜色。
以适用于所有设备的方式正确设置 TextView 文本颜色的样式(目标 API 级别 16+),我缺少什么?
【问题讨论】:
-
你为什么首先使用
DeviceDefault样式?这些总是会因制造商而异。
标签: android android-theme