【开源】ExpandableButtonMenu

ExpandableButtonMenu

  •  https://github.com/lemonlabs/ExpandableButtonMenu

    介绍:

    点击一个button扩展成多个菜单项的menu控件,弹出菜单的同时会增加一个透明层,动画效果见gif,类似与Foursquare应用,需要注意编译的时候要依赖nineoldandroids库。支持2.3版本。

    运行效果:

使用说明:

添加自定义属性声明:

将下面的view添加到布局的根节点之下,(目前只支持RelativeLayout)

1
2
3
4
5
6
7
8
<lt.lemonlabs.android.expandablebuttonmenu.ExpandableMenuOverlay
    android:id="@+id/button_menu"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/circle_home"
/>

有如下属性:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ebm:dimAmount="0.8"        // Screen dim amount when menu is expanded
ebm:mainButtonSize="0.25"  // Main button size in % of screen height
ebm:otherButtonSize="0.22" // Expanded menu button size in % of screen height
ebm:distanceY="0.17"       // Distance between expanded and collapsed button in screen % of screen height
ebm:distanceX="0.28"       // Distance between expanded button in % of screen width
ebm:bottomPad="0.02"       // Button padding in % of screen height
 
// Button drawable and text resources
ebm:closeButtonSrc="@drawable/circle_close"
ebm:leftButtonSrc="@drawable/circle_1"
ebm:midButtonSrc="@drawable/circle_2"
ebm:rightButtonSrc="@drawable/circle_3"
ebm:leftButtonText="@string/action_left"
ebm:midButtonText="@string/action_mid"
ebm:rightButtonText="@string/action_right"

在activity或者Fragment中添加回调方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
menuOverlay = (ExpandableMenuOverlay) findViewById(R.id.button_menu);
menuOverlay.setOnMenuButtonClickListener(new ExpandableButtonMenu.OnMenuButtonClick() {
    @Override
    public void onClick(ExpandableButtonMenu.MenuButton action) {
        switch (action) {
            case MID:
            // do stuff and dismiss
            menuOverlay.getButtonMenu().toggle();
            break;
            case LEFT:
            // do stuff
            break;
            case RIGHT:
            // do stuff
            break;
        }
    }
});

posted on 2015-04-03 10:49  wasdchenhao  阅读(340)  评论(0)    收藏  举报

导航