【发布时间】:2015-08-26 09:00:08
【问题描述】:
我是一名 Android 新手,编写了我的第一个使用操作栏和设计支持库的应用程序。但是,当我展开菜单时,它具有黑色背景色。在我应用材料设计之前,菜单具有默认的灰色。我的 colors.xml 文件中没有任何深色。我怎样才能恢复正常的颜色? 下面是我在styles.xml中创建的主题:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
</style>
当我删除工具栏中的应用程序主题时,我恢复了正常颜色,但操作栏文本和 3 个垂直点的颜色变为黑色。以下是我的activity_main的相关部分:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</LinearLayout>
【问题讨论】:
-
只是为了确认一下,您是否将主题添加到 Android 清单中?
-
@AbdullahAsendar:是的。 Apptheme 是默认的清单主题。我用自己的设置覆盖了现有的主题。
-
这可能无济于事,只能尝试将父级更改为 parent="Theme.AppCompat.Light.DarkActionBar"
-
@AbdullahAsendar:它确实会影响菜单背景颜色。我已经更新了我的问题。
-
希望这会有所帮助:exoguru.com/android/material-design/navigation/… __________ android4devs.com/2015/01/… ____ 都为我工作