android底部弹出圆角矩形菜单,GitHub - MrGaoGang/luckly_popup_window: Android开发使用PupopWindow在指定View的上下左右动态显示菜单列表...

luckly_popup_window

欢迎大家Star😯

PupopWindow动态获取显示的位置,并添加指示箭头

效果图

image.gif

showbottom.png

目录:

引用包 68747470733a2f2f6a69747061636b2e696f2f762f6d7267616f67616e672f6c75636b6c795f706f7075705f77696e646f772e737667

Step 1.在根 build.gradle中添加如下依赖

allprojects {

repositories {

...

maven { url 'https://jitpack.io' }

}

}

Step 2. 在build.gradle中添加如下依赖

dependencies {

compile 'com.github.mrgaogang:luckly_popup_window:v1.4.1'

}

常用的方法

1、添加数据

添加数据的时候,内容和图片的个数应该相同;如果不需要添加图片的话,那么使用第一个和第四个方法,传递的Bitmap=null即可。

void setData(DataBeans[] strings);

void setData(String[] data, int[] images);

void setData(String[] data, Bitmap[] images);

void setData(List list);

2、设置LucklyPopupWindow的宽度(必须设置)

LucklyPopupWindow的宽度(必须设置);设置的单位是dp。

void setWidth(int widthDp);

3、给每一个Item添加分割线

默认的情况是没有分割线的。需要调用以下方法。

//可以自己添加RecyclerView的分割线

addItemDecoration(RecyclerView.ItemDecoration itemDecoration);

//使用内部封装好了的分割线,传入的参数分别是:方向,颜色,分割线的宽

addItemDecoration(int oritation, int color, int lineHeight);

4、设置背景颜色

也就是设置三角形和矩形框的背景颜色

setBackgroundColor(int backgroundColor);

5、设置PopupWindow显示时Activity其余部分显示灰色程度

取值范围0.0<=darkBackgroundDegree<=1.0f

setDarkBackgroundDegree(float darkBackgroundDegree);

6、设置字体的颜色和大小

setTextColor(int textColor);

setTextSize(int textSize);

7、设置图片不显示以及设置图片大小

setImageDisable(boolean imageDisable);

setImageSize(int widthDp,int heightDp);

8、添加监听事件

void setOnItemClickListener(LucklyPopopWindow.OnItemClickListener onItemClickListener);

9、设置箭头的宽,高,圆角矩形的半径

void setTriangleWidth(int triangleWidth);

void setTrianleHeight(int trianleHeight);

void setRadius(int radius);

10、在某个View下/上显示(自动判断上下)

注意:这个方法必须最后调用。

void showAtLocation(View parentView, View positionView);

11、模仿ios底部弹窗

mLucklyPopopWindow.showInBottom(getWindow().getDecorView());

LucklyPopouWindow的使用方法。

mLucklyPopopWindow = new LucklyPopopWindow(this);

//给popupWindow添加数据

mLucklyPopopWindow.setData(getResources().getStringArray(R.array.popupArray), new int[]{R.mipmap.add, R.mipmap.delete, R.mipmap.modify, R.mipmap.update});

mAdapter.setOnItemClickListener(new RecyclerAdapter.OnItemClickListener() {

@Override

public void onItemClick(View view, int position) {

//必须设置宽度

mLucklyPopopWindow.setWidth(150);

//监听事件

mLucklyPopopWindow.setOnItemClickListener(new LucklyPopopWindow.OnItemClickListener() {

@Override

public void onItemClick(int position) {

Toast.makeText(MainActivity.this, "点击的位置" + position, Toast.LENGTH_SHORT).show();

mLucklyPopopWindow.dismiss();

}

});

//添加分割线(可选)

mLucklyPopopWindow.addItemDecoration(LucklyPopopWindow.VERTICAL,Color.GRAY,1);

//设置image不显示(可选)

// mLucklyPopopWindow.setImageDisable(true);

//设置image的大小(可选)

mLucklyPopopWindow.setImageSize(20,20);

//显示popopWindow

mLucklyPopopWindow.showAtLocation(getWindow().getDecorView(), view);

}

});

欢迎关注我的微信公众号一起学习Mendix和Android:

wechat.jpg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值