应用程序主题文本颜色在三星 Galaxy Tab 4 上被忽略
App Theme's TextColor being ignored on Samsumg Galaxy Tab 4
我有一个 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>
这在我能找到的每台设备上都能很好地进行测试。但是,我有一些用户 运行 在 Samsung 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"
但据我了解,这只是为了影响文本大小而不是颜色。
要以适用于所有设备(针对 API 级别 16+)的方式正确设置 TextView 文本颜色的样式,我缺少什么?
如果您想要在所有设备上使用一致的主题,您应该避免使用任何 DeviceDefault
样式,因为这些样式是由各个制造商定制的。
我建议使用其中一种 AppCompat TextAppearance 样式,例如 Theme.AppCompat.Medium
。
我有一个 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>
这在我能找到的每台设备上都能很好地进行测试。但是,我有一些用户 运行 在 Samsung 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"
但据我了解,这只是为了影响文本大小而不是颜色。
要以适用于所有设备(针对 API 级别 16+)的方式正确设置 TextView 文本颜色的样式,我缺少什么?
如果您想要在所有设备上使用一致的主题,您应该避免使用任何 DeviceDefault
样式,因为这些样式是由各个制造商定制的。
我建议使用其中一种 AppCompat TextAppearance 样式,例如 Theme.AppCompat.Medium
。