module链接:https://download.csdn.net/download/meixi_android/10839835
接入module方法:https://blog.csdn.net/meixi_android/article/details/84655666
1、activity实现步骤
layout文件布局——DrawerLayoutContent_ID是抽屉内容id,drawer:DrawerLayoutHandler_ID是抽屉把手id,
<?xml version="1.0" encoding="utf-8"?> <com.example.lenovo.drawerlibrary.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:drawer="http://schemas.android.com/apk/res-auto" android:id="@+id/dial_drawer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" drawer:DrawerLayoutContent_ID="@+id/drawerContent" drawer:DrawerLayoutHandler_ID="@+id/drawerHandle" drawer:DrawerLayout_ID="@+id/drawer2"> <RelativeLayout android:id="@+id/drawer2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <Button android:id="@+id/drawerHandle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@color/transparent" android:text="把手" /> <LinearLayout android:id="@+id/drawerContent" android:layout_width="fill_parent" android:layout_height="300dp" android:layout_below="@+id/drawerHandle" android:background="@color/colorAccent" android:gravity="center" android:orientation="vertical"> <Button android:id="@+id/click" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="底部上滑view" /> <Button android:id="@+id/click1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="click" /> <Button android:id="@+id/click2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="click" /> </LinearLayout> </RelativeLayout> </com.example.lenovo.drawerlibrary.DrawerLayout>
2、activity代码
public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.shanghua); mDrawerLayout = (DrawerLayout) findViewById(R.id.dial_drawer); mDrawerLayout.setInitialState(DrawerLayout.State.Close); //set drawer initial state: open or close mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void drawerOpened() { } @Override public void drawerClosed() { } }); } }