FlowingMenuLayout,水滴样式抽屉

先看看效果

FlowingMenuLayout,水滴样式抽屉_第1张图片

搞起

依赖 

 implementation 'com.mxn.soul:flowingdrawer-core:2.1.0'
 implementation 'com.nineoldandroids:library:2.4.0'

布局

  
        //主界面布局
        

            
            

主界面布局跟抽屉布局要用一个layout包裹起来

使用

 //初始化 flowingdrawer
        flowingDrawer=findViewById(R.id.drawerlayout);
        //flowingdrawer触摸模式
        flowingDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
        //flowingdeawer监听
        flowingDrawer.setOnDrawerStateChangeListener(new ElasticDrawer.OnDrawerStateChangeListener() {
            @Override
            public void onDrawerStateChange(int oldState, int newState) {
                Log.e("onDrawerStateChange","oldState="+oldState+"-----newState"+newState);
            }
            /**
             * openRatio:偏移比例
             * offsetPixels:偏移像素
             * */
            @Override
            public void onDrawerSlide(float openRatio, int offsetPixels) {
                Log.e("onDrawerSlide","openRatio="+openRatio+"-----offsetPixels"+offsetPixels);
                //关闭
                if (openRatio==0){
                text1.setText("已关闭");
                }else{
                    text2.setText("已打开");
                }
            }
        });

        //打开
        mBtn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                flowingDrawer.openMenu();
            }
        });
        //关闭
        mBtn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                flowingDrawer.closeMenu();
            }
        });

 

你可能感兴趣的:(FlowingMenuLayout,水滴样式抽屉)