我在活动中添加了一个滑动抽屉,但它更改了操作栏的一部分的颜色
如何使操作栏的颜色均匀?
编辑:这是我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/layout_NotesActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp">
<include layout="@layout/notes_activity_content" />
<android.support.design.widget.NavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:itemTextColor="@android:color/background_dark"
app:menu="@menu/menu_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
答案 0 :(得分:0)
您必须在AppBarLayout中为参考设置颜色。请检查下面的代码
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_Drawer"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/transparent"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:background="@drawable/gradiant_splash"
android:scaleType="centerCrop" />
</android.support.design.widget.AppBarLayout>
答案 1 :(得分:0)
如果您不熟悉Android Studio或一般的Android,最好使用预先创建的“活动”。例如, DrawerActivity ,它具有您所需的一切,并且从一开始就看起来很棒。
只需创建一个新的Activity,然后从显示的不同布局中选择它即可。
如果这样做,您只需要在资源/值/颜色中更改颜色即可。
之所以这么说是因为您似乎不了解应在活动中添加抽屉的方式。如果其他人已经为您做到了,为什么还要重新发明轮子呢?
如果您不想这样做,请查看https://developer.android.com/training/implementing-navigation/nav-drawer