我最近将我的操作栏更改为新的 Material 设计。我使用新的工具栏小部件来显示 Activity 上的栏,但 Activity 上的所有 TextView 都是白色的。我怀疑我的主题中的“android:textColorPrimary”会更改 TextView 的颜色,但我需要它来使 actiobar 标题变为白色。
工具栏小部件:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
app:theme="@style/Theme.Custom"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
主题.自定义:
<style name="Theme.Custom" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">@android:color/holo_orange_dark</item>
</style>
最佳答案
好吧,我找到了导致问题的原因。在 AndroidManifest.xml
中,当我想在一个 Activity 上定义一个没有 ActionBar
的主题时,我使用了 Theme.AppCompat.NoActionBar
工具栏> 而不是 Theme.AppCompat.Light.NoActionBar
关于Android 应用程序兼容性 21 : All my textview are white,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26684578/