编辑:我刚才意识到它实际上并不是强调色。我尝试改变强调颜色,当它在其他地方改变时,我的导航项目的颜色保持粉红色。我只是假设它是强调色,因为它与它相似。现在我不知道那种颜色来自哪里。
我刚刚注意到,在我的应用中,导航抽屉项目是强调色,而不是在Android 8上运行时的黑色。
在Android 7中,它们仍然是黑色的,只有Android 8才有所不同。另外,在Android Studio中查看设计预览时,它会将它们显示为API 26(Android 8)的黑色,但在运行时它是强调色。
以下是一些展示此问题的图片:
这就是Android Studio的设计预览和8之前版本的样子:
在Android 8上:
请注意,当项目处于活动状态时,原色仍然有效(这就是我想要的方式),但是如果我尝试将图标或文本的色调更改为黑色,则当它不再能够更改为原色时活跃,因此无法解决问题。
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>
有谁知道为什么会这样?
答案 0 :(得分:5)
好的,我设法解决了。事实证明我正在使用api等级为23的主题的依赖关系,他们在Android 8中破解。通过升级我的依赖关系,目标SDK并将SDK版本编译为26来解决问题。
答案 1 :(得分:0)
获得解决方案 - 导航抽屉菜单项文本颜色粉红色问题在android 8中.. 我也面临同样的问题发生在奥利奥(MiA1)。
*将编译SDK版本更改为25。
compileSdkVersion 25
更新下面提到的那些库(app.gradle)
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:palette-v7:25.3.0'
答案 2 :(得分:0)
对于任何拥有较新的SDK版本的人来这里
:这为我解决了问题