编辑:我刚刚意识到它实际上不是重音颜色。我尝试改变口音的颜色,并在其他地方改变时,我的导航项目的颜色保持粉红色。我只是认为这是重音的颜色,因为它与它相似。现在我不知道颜色来自哪里。导航抽屉项目是粉红色而不是黑色只在Android 8
我刚刚注意到在我的应用程序在Android上运行8时,导航抽屉项目是强调色,而不是被黑
在Android的7,他们仍然是黑色的,只有Android的8,这是不同的。另外,在Android Studio中查看设计预览时,它会将它们显示为API 26(Android 8)的黑色,但运行时它是重音颜色。
以下是演示该问题,一些图片:
这就是它看起来像在Android Studio中的设计预览和8之前的版本:
而在Android上8:
请注意,主要颜色仍然工作时,项目是活动的(这是我想要的),但如果我尝试改变图标的色调或te xt将其变为黑色时,它不再能够在活动时变为主要颜色,因此不能用作解决方法。
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#F44336</color>
<color name="colorPrimaryDark">#D32F2F</color>
<color name="colorAccent">#FF4081</color>
</resources>
XML进行导航活动
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main_nav"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main_nav"
app:menu="@menu/activity_main_nav_drawer" />
</android.support.v4.widget.DrawerLayout>
没有人有任何想法,为什么这可能发生?
您可以添加style.xml和color.xml文件 –
对不起,应该包括那些开头。现在包括。 – procinct
看起来正确。你可以清理你的构建,卸载应用程序并运行它。 –