Android 底部上拉抽屉view

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()
            {

            }
        });
    }
}

关闭抽屉效果

打开抽屉效果

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值