第三方开源库:给View添加数字:ShortcutBadger + BadgeView

来源:互联网 发布:数据库处理流程图 编辑:程序博客网 时间:2024/06/10 19:14

ShortcutBadger

给app的快捷图标添加数字
github:https://github.com/leolin310148/ShortcutBadger
在联想手机上未成功!

效果图

这里写图片描述

gradle

repositories {    mavenCentral()}dependencies {    compile "me.leolin:ShortcutBadger:1.1.13@aar"}

* Add the codes below:*

int badgeCount = 1;ShortcutBadger.applyCount(context, badgeCount); //for 1.1.4+ShortcutBadger.with(getApplicationContext()).count(badgeCount); //for 1.1.3

If you want to remove the badge

ShortcutBadger.removeCount(context); //for 1.1.4+ShortcutBadger.with(getApplicationContext()).remove();  //for 1.1.3orShortcutBadger.applyCount(context, 0); //for 1.1.4+ShortcutBadger.with(getApplicationContext()).count(0); //for 1.1.3

BadgeView

给应用内的图标添加数字,不包含app的快捷图标

效果图

这里写图片描述

Gradle

compile 'q.rorbin:badgeview:1.0.0'

代码

添加数字

new QBadgeView(context).bindTarget(textview).setBadgeNumber(5);

可以是给Bottombar的个tab添加数字

View tab1 = bottomBar.findViewById(R.id.tab1);new QBadgeView(this).bindTarget(tab1).setBadgeNumber(5);

这里写图片描述
取消数字:

qBadgeView.bindTarget(tv).hide(true);

方法说明

code 说明 setBadgeNumber 设置数值 setBadgeNumberSize 设置数值大小 setBadgeNumberColor 设置数值颜色 setExactMode 设置是否显示精确模式数值 setBadgeGravity 设置Badge相对于TargetView的位置 setGravityOffset 设置外边距 setBadgePadding 设置内边距 setBadgeBackgroundColor 设置背景色 setShowShadow 设置是否显示阴影 setOnDragStateChangedListener 打开拖拽消除模式并设置监听 hide 隐藏Badge

源码

https://git.oschina.net/libraryDemo/BadgeView02

1 0
原创粉丝点击