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

android 侧滑菜单DrawerLayout

2015-03-25 15:58 441 查看
一:最简单的侧滑菜单

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/id_drawerlayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <FrameLayout
        android:id="@+id/id_framelayout2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#cd9a5b" >
    </FrameLayout>

    <LinearLayout
        android:id="@+id/id_linearlayout2"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#45b97c"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/id_lv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:divider="#CD853F"
            android:dividerHeight="2dp" >
        </ListView>
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>


@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mydrawer);
    }


二:改变滑动灵敏度

两种方式:

反射修改滑动区域,重载dispatchTouchEvent
http://stackoverflow.com/questions/17699869/how-to-show-the-drawerlayout-when-sliding-from-left-to-right-no-matter-where http://blog.csdn.net/lmj623565791/article/details/41531475 http://blog.csdn.net/crazy1235/article/details/41696291 http://www.kwstu.com/ArticleView/kwstu_201408210609378926
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: