Home

Awesome

PopupMenuView

此库主要实现了一个类似iOS中的UIMenuController控件的Popup控件。 主要控件如下:

预览图片

Demo

安装 apk 文件预览效果,或者通过下面二维码去下载安装:

DEMO下载二维码

Usage

Use Gradle:

compile 'me.kareluo.ui:popmenu:1.1.0'

Or Maven:

<dependency>
  <groupId>me.kareluo.ui</groupId>
  <artifactId>popmenu</artifactId>
  <version>1.1.0</version>
  <type>pom</type>
</dependency>

Sample

PopupMenuView可以通过menu布局文件加载出预先准备的菜单:

// 根据menu资源文件创建
PopupMenuView menuView = new PopupMenuView(this, R.menu.menu_pop, new MenuBuilder(context));

// 设置点击监听事件
menuView.setOnMenuClickListener(new OptionMenuView.OnOptionMenuClickListener() {
    @Override
    public boolean onOptionMenuClick(int position, OptionMenu menu) {
        Toast.makeText(this, menu.getTitle(), Toast.LENGTH_SHORT).show();
        return true;
    }
});

// 显示在mButtom控件的周围
menuView.show(mButtom);

或者通过代码添加:

menuView.setMenuItems(Arrays.asList(
    new OptionMenu("复制"), new OptionMenu("转发到朋友圈"),
    new OptionMenu("收藏"), new OptionMenu("翻译"),
    new OptionMenu("删除")));

默认的显示方位为:上、下、左、右,即按照这种顺序测试界面是否可以显示下菜单,可以如下方式自定义:

menuView.setSites(PopupView.SITE_BOTTOM, PopupView.SITE_LEFT, PopupView.SITE_TOP, PopupView.SITE_RIGHT);

Update Logs

v1.0.0

v1.0.1

v1.0.2

v1.0.3

v1.0.4

v1.0.5

v1.1.0

License

Copyright 2016 kareluo.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.