我一直致力于对我的应用进行 Material Design 改造。我很好奇您将如何更改 activity_main xml 代码以使抽屉导航滑动打开而不覆盖包含那个华丽的新切换按钮的工具栏。我有什么想法可以做到这一点吗?
activity_main:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<RelativeLayout
android:id="@+id/drawerView"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="start" >
<ListView
android:id="@+id/drawerList"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/nav_border"
android:divider="@null" />
</RelativeLayout>
<!--
<fragment
android:id="@+id/fragment1"
android:name="com.shamu11.madlibsportable.MadlibsSelect"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
-->
</android.support.v4.widget.DrawerLayout>
最佳答案
我使用以下布局实现了它: 抽屉.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.toolbar.Drawer" >
<include
android:id="@+id/tool1"
layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tool1" >
<FrameLayout
android:id="@+id/mainContent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<!-- Nav drawer -->
<ListView
android:id="@+id/drawerList"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@android:color/white"
android:divider="@android:color/white"
android:dividerHeight="8dp"
android:drawSelectorOnTop="true"
android:headerDividersEnabled="true" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
工具栏.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app1="http://schemas.android.com/apk/res/com.example.toolbar"
android:id="@+id/my_awesome_toolbar"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app1:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app1:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
</android.support.v7.widget.Toolbar>
关于android - 让抽屉导航滑到工具栏/操作栏下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26821438/