android布局上上加红点数字,GitHub - liyanxi/BadgeView: view 上添加小红点(含数字)

BadgeView

add badgeview to any targetView in Android

1947f15dc57f3ab1cf9bd892563ee1a7.png

Usage

Step1

Add dependencies in build.gradle.

dependencies {

compile 'com.itingchunyu.badgeview:badgeview:1.0.5'

}

注释:v1.0.5版本引用名称作如下修改

IBadgeTextView===>BadgeTextView

IBadgeViewImpl ===> IBadgeView

IBadgeView ===> BadgeViewUtil

以上三个类内部实现不变

BadgeViewUtil工具类

XML attributes自定义属性(BadgeTextView、BaseBadgeView)可使用

Step2

使用样例

//第一种方式:可依附任意view(无限制:初始定位右上角)

TextView tv = (TextView) findViewById(R.id.tv);

BadgeTextView mBadgeView=new BadgeTextView(this);

mBadgeView.setTargetView(tv);//设置目标targetView(可任意:此处只做演示)

mBadgeView2.setBadgeCount(92)//数量(0:表示小红点)

.setmDefaultRightPadding(20)//右依附视图距离

.setmDefaultTopPadding(20);//上依附视图距离

//第二种方式:布局中直接引用(仅作为TextView是用)

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:background="#55ff0000"

android:gravity="center">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:background="#999"

android:drawableTop="@mipmap/ic_launcher"

android:gravity="center"

android:text="" />

android:id="@+id/btv_null"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="right|top"

android:layout_marginRight="15dp"

android:layout_marginTop="5dp"

android:gravity="center"

app:badge_count="10"

app:badge_none_show="true" />

预知详情使用请参考demo

参考实例代码

License

Copyright 2016 itingchunyu

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

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值