zoukankan      html  css  js  c++  java
  • android側滑菜单-DrawerLayout的基本使用

    眼下主流App开发中,部分是以側滑菜单为主布局架构,曾经做android側滑菜单时。大多选择使用github上的第三方开源框架SildingMenu,可是这个框架还是稍显笨重。好消息是google已经开源了一个側滑菜单布局组件:DrawerLayout。DrawerLayout是V4包中的组件。也是直接继承于ViewGroup类。所以这个类也是一个容器类。使用DrawerLayout能够轻松的实现抽屉效果,使用DrawerLayout的步骤有下面1几点:

    1)在DrawerLayout中,第一个子View必须是显示内容的view,而且设置它的layout_width和layout_height属性是match_parent.

    2)第二个view是抽屉view,而且设置属性layout_gravity="left|right",表示是从左边滑出还是右边滑出。设置它的layout_height="match_parent"

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawerlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >
     
        <TextView
            android:id="@+id/textview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="content" />
     
        <ListView
            android:id="@+id/listview"
            android:layout_width="80dp"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:background="#FFB5C5" />
     
    </android.support.v4.widget.DrawerLayout>


  • 相关阅读:
    Spring温故而知新 – bean的装配
    Lambda表达式和表达式树
    委托的内部机制
    委托(C#)
    linux wdcp安装
    linux各个文件夹作用
    linux基本命令
    python调用html内的js方法
    Win10在右键菜单添加“在此处打开命令窗口”设置项
    python read文件的r和rb的区别
  • 原文地址:https://www.cnblogs.com/gccbuaa/p/6950768.html
Copyright © 2011-2022 走看看