jon*_*ycg 6 android android-layout
编辑:我刚刚意识到它实际上并不是强调色.我尝试改变强调颜色,当它在其他地方改变时,我的导航项目的颜色保持粉红色.我只是假设它是强调色,因为它与它相似.现在我不知道那种颜色来自哪里.
我刚刚注意到,在我的应用程序中,导航抽屉项目是强调颜色,而不是在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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
导航活动的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>
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会发生这种情况?
| 归档时间: |
|
| 查看次数: |
1296 次 |
| 最近记录: |