All Projects → Ryan-Shz → MenuPopupView

Ryan-Shz / MenuPopupView

Licence: MIT license
一款仿iOS长按菜单弹窗的自定义控件

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to MenuPopupView

ScaleView
ArcScaleView,ScaleView,刻度尺选择器,包括弧形刻度尺选择器和直尺形刻度尺选择器
Stars: ✭ 53 (+103.85%)
Mutual labels:  custom-view
easyCountDownTimer
A simple android library to countdown timer textview for api 14+
Stars: ✭ 61 (+134.62%)
Mutual labels:  custom-view
MenuPopOverView
A custom PopOverView looks like UIMenuController works on iPhone.
Stars: ✭ 61 (+134.62%)
Mutual labels:  uimenucontroller
XCPullToLoadMoreListView
XCPullToLoadMoreListView-下拉加载更多ListView控件(仿QQ、微信聊天对话列表控件)
Stars: ✭ 24 (-7.69%)
Mutual labels:  custom-view
XCArcProgressView
Android开口圆环比例进度View(高仿猎豹清理大师内存占用比例View)
Stars: ✭ 28 (+7.69%)
Mutual labels:  custom-view
password-view
Android password animation
Stars: ✭ 43 (+65.38%)
Mutual labels:  custom-view
RatioLayouts
A collection of ViewGroups which can have a constant width to height ratio.
Stars: ✭ 19 (-26.92%)
Mutual labels:  custom-view
SkeletonPlaceholderView
A library for creating dynamic skeleton view
Stars: ✭ 25 (-3.85%)
Mutual labels:  custom-view
Circular-Progress-View
A customisable circular progress view for android.
Stars: ✭ 39 (+50%)
Mutual labels:  custom-view
YuanaItemSettingView
Customizable Item Setting View Android
Stars: ✭ 15 (-42.31%)
Mutual labels:  custom-view
android-thinkmap-treeview
Tree View; Mind map; Think map; tree map; custom view; 自定义;关系图;树状图;思维导图;组织机构图;层次图
Stars: ✭ 314 (+1107.69%)
Mutual labels:  custom-view
WechatPopupWindow
高仿微信聊天界面长按弹框样式
Stars: ✭ 71 (+173.08%)
Mutual labels:  custom-view
Custom-Grid-View
Custom Drag and Drop Grid for Home Assistant
Stars: ✭ 103 (+296.15%)
Mutual labels:  custom-view
CustomView
custom view
Stars: ✭ 13 (-50%)
Mutual labels:  custom-view
Image-Support
Add badge with counter to ImageView Android.
Stars: ✭ 128 (+392.31%)
Mutual labels:  custom-view
IconDotTextView
Convenient to add a View which contains icon, text and red dot.
Stars: ✭ 22 (-15.38%)
Mutual labels:  custom-view
Android-Code-Demos
📦 Android learning code demos.
Stars: ✭ 41 (+57.69%)
Mutual labels:  custom-view
flasto
A FLoating ASsistive TOuch library for android!
Stars: ✭ 15 (-42.31%)
Mutual labels:  custom-view
AACustomFont
[UNMAINTAINED] AACustomFont is a lightweight custom font binder in XML directly in TextView, Button, EditText, RadioButton, CheckBox tags. The library is aimed to avoid custom views for custom fonts in XML and to minimize the JAVA code for setting the TypeFaces for each view.
Stars: ✭ 76 (+192.31%)
Mutual labels:  custom-view
SquaresLoadingView
A SquaresLoadingView based on android.View, nicely rotation、easy to use.
Stars: ✭ 26 (+0%)
Mutual labels:  custom-view

MenuPopupView

Download

一款仿iOS长按菜单弹窗的自定义控件。

效果图

导入

implementation 'com.ryan.github:menupopupview:1.0.0'

使用

1. 自定义MenuPopupAdapter

public class TestPopupAdapter extends MenuPopupAdapter<String> {

    private List<String> mData;

    public TestPopupAdapter(List<String> data) {
        mData = data;
    }

    // 返回Item View视图对象
    @Override
    public View getView(View container, int position) {
        View view = LayoutInflater.from(container.getContext()).inflate(R.layout.test_item, null);
        TextView tv = (TextView) view.findViewById(R.id.label);
        tv.setText(getItem(position));
        return view;
    }

    /**
     * 获取item数
     *
     * @return item数量
     */
    @Override
    public int getItemCount() {
        return mData.size();
    }

    /**
     * 获取position位置的数据对象
     *
     * @param position 位置索引
     * @return 数据对象
     */
    @Override
    public String getItem(int position) {
        return mData.get(position);
    }
}

2. 创建PopupView并指定Adapter

List<String> menus = new ArrayList<>();
menus.add("default");
menus.add("copy");
MenuPopupAdapter<String> adapter = new TestPopupAdapter(menus);
PopupView popupView = new PopupView(this);
popupView.setAdapter(adapter);

3. 设置依附anchor方向并显示

// 显示在anchor底部
popupView.setPopupLocation(PopupLayout.PopupLocation.Bottom);
// 显示在anchor顶部
popupView.setPopupLocation(PopupLayout.PopupLocation.TOP);
// 显示PopupView
popupView.show(v);

4. 动态改变菜单并刷新

adapter.notifyDataSetChanged();

5. 设置分割线颜色

// 设置item的分割线颜色
popupView.setDriverColorResId(int colorResId);
// 设置左右指示器的分割线颜色
popupView.setIndicatorDriverColorResId(int colorResId);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].