我想在工具栏上展开我的导航抽屉,并使状态栏透明。我读了一篇介绍,我必须将工具栏实现到我的Drawer布局的XML文件中。我试了一下,但它没有用。 或者有没有办法,我可以从样式文件夹中更改它?我尝试了几个介绍和教程,但他们没有工作:/
这是我抽屉布局的代码:
<?xml version="1.0" encoding="utf-8"?>
//(............)
<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"
android:backgroundTint="@color/colorPrimary">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@mipmap/ic_launcher_round"
android:layout_marginTop="100dp"
android:layout_gravity="center_horizontal"
/>
<ExpandableListView
android:id="@+id/navigationmenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="220dp"
android:background="@android:color/white">
</ExpandableListView>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
</FrameLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
那是我的应用栏布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.example.example.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/activity_navigation_view" />
</android.support.design.widget.CoordinatorLayout>