:heartpulse:BGABadgeView-Android:heartpulse:
demo中演示了:
微博底部tab显示最新微博条数
微博列表用户头像显示显示右下角vip徽章
微信消息界面用户新消息
微信消息界面订阅号新消息
使用v4包中的RoundedBitmapDrawable制作圆角头像
拖拽删除徽章
爆炸效果参考的 ExplosionField 改成了只有一个View的情况,只刷新徽章附近的区域
效果图
添加 Gradle 依赖
把 maven { url 'https://jitpack.io' } 加入到 repositories 中
添加如下依赖,末尾的「latestVersion」指的是徽章 里的版本名称,请自行替换。
groovy 复制
dependencies {
implementation 'com.github.bingoogolapple.BGABadgeView-Android:api:latestVersion'
annotationProcessor 'com.github.bingoogolapple.BGABadgeView-Android:compiler:latestVersion'
}初始化徽章控件
在项目任意一个类上面添加 BGABadge 注解,例如新建一个类 BGABadgeInit 专门用于初始化徽章控件
需要哪些类具有徽章功能,就把那些类的 Class 作为 BGABadge 注解的参数「下面的代码块给出了例子,不需要的可以删掉对应的行」
再 AS 中执行 Build => Rebuild Project
经过前面三个步骤后就可以通过「cn.bingoogolapple.badgeview.BGABadge原始类名」来使用徽章控件了
接口说明
java 复制
void showCirclePointBadge () ;
void showTextBadge (String badgeText) ;
void hiddenBadge () ;
void showDrawableBadge (Bitmap bitmap) ;
void setDragDismissDelegage (BGADragDismissDelegate delegate) ;
boolean isShowBadge () ;
boolean isDraggable () ;
boolean isDragging () ;自定义属性说明
属性名
说明
默认值
badge_bgColor
徽章背景色
Color.RED
badge_textColor
徽章文本的颜色
Color.WHITE
badge_textSize
徽章文本字体大小
10sp
badge_verticalMargin
徽章背景与宿主控件上下边缘间距离
4dp
badge_horizontalMargin
徽章背景与宿主控件左右边缘间距离
4dp
badge_padding
徽章文本边缘与徽章背景边缘间的距离
4dp
badge_gravity
徽章在宿主控件中的位置
BGABadgeImageView和BGABadgeRadioButton是右上方,其他控件是右边垂直居中
badge_draggable
是否开启拖拽删除徽章
false
badge_isResumeTravel
拖拽徽章超出轨迹范围后,再次放回到轨迹范围时,是否恢复轨迹
false
badge_borderWidth
徽章描边宽度
0dp
badge_borderColor
徽章描边颜色
Color.WHITE
badge_dragExtra
触发开始拖拽徽章事件的扩展触摸距离
4dp
作者联系方式
打赏支持作者
如果您觉得 BGA 系列开源库或工具软件帮您节省了大量的开发时间,可以扫描下方的二维码打赏支持。您的支持将鼓励我继续创作,打赏后还可以加我微信免费开通一年 上帝小助手浏览器扩展/插件开发平台 的会员服务
作者项目推荐
License
复制
Copyright 2015 bingoogolapple
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.