android 侧滑菜单DrawerLayout

时间:2023-01-24 05:26:13



一:最简单的侧滑菜单

<?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://*.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