TopRightMenu
類似手機(jī)QQ界面右上角的彈出菜單,使用recyclerview
和popupwindow
封裝了一下,從此告別繁瑣俊鱼,一步輕松實(shí)現(xiàn)汛聚!
廢話不多說锹安,先看效果圖:
Gif
圖片中看起來比較卡頓,但真機(jī)運(yùn)行是正常的.
APK
下載demo.apk體驗(yàn).
Install
Gradle:
compile 'com.zaaach:toprightmenu:1.0'
or Maven:
<dependency>
<groupId>com.zaaach</groupId>
<artifactId>toprightmenu</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
or 下載library手動(dòng)導(dǎo)入.
Usage
mTopRightMenu = new TopRightMenu(MainActivity.this);
//添加菜單項(xiàng)
List<MenuItem> menuItems = new ArrayList<>();
menuItems.add(new MenuItem(R.mipmap.multichat, "發(fā)起多人聊天"));
menuItems.add(new MenuItem(R.mipmap.addmember, "加好友"));
menuItems.add(new MenuItem(R.mipmap.qr_scan, "掃一掃"));
mTopRightMenu
.setHeight(480) //默認(rèn)高度480
.setWidth(320) //默認(rèn)寬度wrap_content
.showIcon(true) //顯示菜單圖標(biāo)倚舀,默認(rèn)為true
.dimBackground(true) //背景變暗叹哭,默認(rèn)為true
.needAnimationStyle(true) //顯示動(dòng)畫,默認(rèn)為true
.setAnimationStyle(R.style.TRM_ANIM_STYLE)
.addMenuList(menuItems)
.addMenuItem(new MenuItem(R.mipmap.facetoface, "面對面快傳"))
.addMenuItem(new MenuItem(R.mipmap.pay, "付款"))
.setOnMenuItemClickListener(new TopRightMenu.OnMenuItemClickListener() {
@Override
public void onMenuItemClick(int position) {
Toast.makeText(MainActivity.this, "點(diǎn)擊菜單:" + position, Toast.LENGTH_SHORT).show();
}
})
.showAsDropDown(moreBtn, -225, 0); //帶偏移量
// .showAsDropDown(moreBtn)
OK, 拿去玩耍 ~
鏈接
Github地址:TopRightMenu 記得給個(gè)star~