android 侧滑菜单

就是用手一滑才出现,占手机半个多屏幕的菜单。为了美观和页面转跳,很多时候要用到。

实现的话就是使用官方的DrawerLayout,注意这个布局一定要是最顶层的布局。

在DrawerLayout里面直接写代码的话,添加的东西是在侧滑菜单里面的。

要是正文内容(就是没出现侧滑菜单的那部分)的东西,要写在FrameLayout里面。当然FrameLayout是在DrawerLayout里面的。

看看效果图:

 

正文部分(有个hehe按扭):

android 侧滑菜单_第1张图片

 

侧滑部分:

android 侧滑菜单_第2张图片

 

我们要做的事情,其实就是往侧滑菜单还有正文部分添加内容和功能,具体的代码如下:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/id_drawerlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<FrameLayout android:id="@+id/id_framelayout" android:layout_width="match_parent" android:layout_height="match_parent" > 这里是正文部分的内容(省略) </FrameLayout>


<LinearLayout android:id="@+id/id_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#E0EEE0" android:orientation="vertical" >     这里是菜单里面的内容 </LinearLayout> </android.support.v4.widget.DrawerLayout>

 


你可能感兴趣的:(android 侧滑菜单)