带弹性的侧滑菜单

作者: 5afd372c86ba | 来源:发表于2017-09-29 10:53 被阅读22次
    名称 JPSpringMenu
    语言 Android
    平台 GitHub
    作者 peng8350
    链接 点此进入

    常规的安卓侧滑菜单大家肯定见过,今天给大家推荐一款带弹性的侧滑菜单,话不多说,看效果图。


    效果图

    使用方法

    1. 添加依赖
    dependencies {
        compile 'com.jpeng:jpspringmenu:$latestVersion'
    }
    
    1. 在Activity中添加
    // R.layout.view_menu is your custom menu Layout resourceId 
    SpringMenu menu = new SpringMenu(this,R.layout.view_menu);
    
    @Override 
    public boolean dispatchTouchEvent(MotionEvent ev) { 
         return menu.dispatchTouchEvent(ev); 
    }
    
    1. 配置menu
        mSpringMenu.setMenuSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(20,3));
        mSpringMenu.setChildSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(20, 5));
    
        //opened CallBack
        void onMenuOpen();
        //closed CallBack
        void onMenuClose();
        
        /**
         * When the menu is opening or closing,the method will call back(contain dragging arc)
         * @value: 0f-2f,0f indicates that the menu is closed,2f indicates that opening
         * @bouncing: this Boolean value is used to determine whether or not it is in bouncing,
         * when in bouncing,The value is infinitely close to 2f,else is 0f
         */
        void onProgressUpdate(float value,boolean bouncing);
    
         //Content Page dark effect
         setFadeEnable(boolean);
         
         // distance of Allow the menu to begin dragging
         setDragOffset(float);
         
         setMenuListener(MenuListener);
         
         setDirection(int direction);
    

    相关文章

      网友评论

        本文标题:带弹性的侧滑菜单

        本文链接:https://www.haomeiwen.com/subject/zrabextx.html