Giter Site home page Giter Site logo

weibopopupmenu's Introduction

仿微博添加按钮弹出菜单

Download

image image

版本更新须知(1.0.5)

增加MenuItem的获取,预设的的个别几项属性设置settter和getter

版本更新(1.0.7)

增加菜单被关闭监听

1.依赖

依赖库分发在Jcenter。

dependencies {
compile 'com.lrq.menu:addpopmenu:latestVersion'
}

2.使用

在对应要弹出的按钮事件上加上这段代码

    mPopMenu = new PopMenu.Builder().attachToActivity(MainActivity.this)
                .addMenuItem(new PopMenuItem("广场", getResources().getDrawable(R.drawable.tabbar_compose_idea)))
                .addMenuItem(new PopMenuItem("私密", getResources().getDrawable(R.drawable.tabbar_compose_photo)))
                .addMenuItem(new PopMenuItem("家庭圈", getResources().getDrawable(R.drawable.tabbar_compose_headlines)))

                .setOnItemClickListener(new PopMenuItemListener() {
                    @Override
                    public void onItemClick(PopMenu popMenu, int position) {


                        Toast.makeText(MainActivity.this, "你点击了第" + position + "个位置", Toast.LENGTH_SHORT).show();


                    }
                })
                .build();
       mPopMenu.show();         
                

3.自定义

(1)在PopMenu以下属性的set方法都可以自定义相对应的自定义功能(调用.build()后调用,show()调用之前)

   /**
     * 关闭按钮距离屏幕底部位置单位dp
     */
   private int mCloseMenuMarginbottom=15;

    /**
     * 背景颜色
     */
    private int mBackGroundColor=Color.parseColor("#f0f3f3f3");

    /**
     * 关闭按钮的图片
     */
    private int mCloseButtomResourceid=R.drawable.tabbar_compose_background_icon_close;

    /**
     * Menu相对于屏幕顶部的距离的的倍数因子(屏幕高度减去菜单本身高度剩下部分除以这个倍数因子)
     */

    private   float mMarginTopRemainSpace=1.5f;

    /**
     * 是否错位弹出菜单
     */
    private   boolean mIsmalpositionAnimatOut=true;

    /**
     * 错位动画时间(毫秒)默认50
     */
    private   int malposition=50;
    

(2)在PopMenu以下属性的set方法都可以自定义相对应的自定义功能(调用.build()前调用)

    /**
     * 一行多少列,默认三列
     *
     */
        public Builder columnCount(int count) {
            this.columnCount = count;
            return this;
        }

    /**
     *添加菜单项
     *
     */
        public Builder addMenuItem(PopMenuItem menuItem) {
            this.itemList.add(menuItem);
            return this;
        }
    /**
     * 动画执行时间,默认300毫秒
     *
     */
        public Builder duration(int duration) {
            this.duration = duration;
            return this;
        }
    /**
     * 拉力系数,默认10
     *
     */
        public Builder tension(double tension) {
            this.tension = tension;
            return this;
        }

    /**
     * 摩擦力系数默认5
     *
     */
        public Builder friction(double friction) {
            this.friction = friction;
            return this;
        }
    /**
     * item水平之间的间距
     */
        public Builder horizontalPadding(int padding) {
            this.horizontalPadding = padding;
            return this;
        }
    /**
     * item竖直之间的间距
     */
        public Builder verticalPadding(int padding) {
            this.verticalPadding = padding;
            return this;
        }
    /**
     * item点击监听器
     */
        public Builder setOnItemClickListener(PopMenuItemListener listener) {
            this.popMenuItemListener = listener;
            return this;
        }
    

weibopopupmenu's People

Contributors

joelan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

weibopopupmenu's Issues

老哥,似乎不能设置背景图片和关闭按钮的图片诶

我在build后面执行这个操作.build().setmCloseButtomResourceid(R.drawable.unpressplus),报错说参数incompatible type,我看你demo里面关闭图片也是.png,可能背景是只能设置颜色属性,但是关闭按钮的图片不知道为什么会报incompatible type,求指导.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.