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"><RelativeLayoutandroid:id="@+id/drawer2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"><Buttonandroid:id="@+id/drawerHandle"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:background="@color/transparent"android:text="把手"/><LinearLayoutandroid: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"><Buttonandroid:id="@+id/click"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:text="底部上滑view" /><Buttonandroid:id="@+id/click1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:text="click" /><Buttonandroid: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;@Overrideprotected 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 closemDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener(){@Overridepublic void drawerOpened(){}@Overridepublic void drawerClosed(){}});} }