您的位置:首页 > 移动开发 > Android开发

Android Material Design 之 DrawLayout

2020-02-17 04:47 323 查看

Drawlayout

 DrawerLayout 最好放在根布局,DrawerLayout之下有两个子布局,一个是FramLayout和TextView

第一个子布局则是主界面布局,第二个子布局则是侧滑的菜单界面

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.us.androiddesign.drawerLayout.DrawerLayoutActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/holo_green_light"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat">

</android.support.v7.widget.Toolbar>
</FrameLayout>
<TextView            <!--第二个子布局可以选择其他的,比如ListView等-->
android:id="@+id/chehua"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
            android:layout_gravity="start"  <!--这里特别注意这个属性必须要,否则侧滑菜单用不了-->
android:text="这是一个侧滑菜单1"/>

</android.support.v4.widget.DrawerLayout>

 

 

转载于:https://my.oschina.net/quTMD/blog/1551363

  • 点赞
  • 收藏
  • 分享
  • 文章举报
chimao6683 发布了0 篇原创文章 · 获赞 0 · 访问量 95 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: