自定义view实现未读消息提示(小红点)
来源:互联网 发布:java数字金字塔代码 编辑:程序博客网 时间:2024/06/05 06:30
转载:http://blog.csdn.net/qq_28268507/article/details/70314844
自定义view继承RadioButton
public class NotifyRadioButton extends RadioButton {Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);float radius;boolean notify;public NotifyRadioButton(Context context, AttributeSet attrs) { super(context, attrs); paint.setColor(Color.RED); radius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, 12.0f, context.getResources().getDisplayMetrics());}@Overrideprotected void onDraw(Canvas canvas) { super.onDraw(canvas); if (notify) { //获取到DrawableTop, 0 drawableleft 1 drawabletop 2 drawableright 3 drawablebottom Drawable drawable = getCompoundDrawables()[1]; //获取到Drawable的left right top bottom的值 Rect bounds = drawable.getBounds(); //float cx, float cy, float radius, @NonNull Paint paint float cx = getMeasuredWidth() / 2 + bounds.width() / 2 - radius / 2; float cy = getPaddingTop() + bounds.height() / 4; canvas.drawCircle(cx, cy, radius, paint); }}/** * 新消息提醒 * * @param notify */public void notify(boolean notify) { this.notify = notify; invalidate();}}
在代码中,通过id找到控件,调用notify(true),就可看到小红点的显示
阅读全文
0 0
- 自定义view实现未读消息提示(小红点)
- Android自定义未读消息提示View
- 自定义未读消息提示
- 安卓Toast显示提示消息(自定义view,根据子线程消息显示提示)
- 仿微信消息数目提示的自定义view
- Android 自定义View之消息提示控件
- wing带你玩转自定义view系列(2) 简单模仿qq未读消息去除效果
- [Android开发] 自定义View之消息数量提示View-TipView
- Android中的BGABadgeView未读消息提示小红点
- android底部菜单栏demo(未读消息提示)
- Android设置未读消息提示,BadgeView
- Android自定义小红点消息提示
- Android自定义小红点消息提示
- 自定义View实现控件晃动提示效果
- 实现淘宝订单(比如订单生成、未支付的订单等等)自定义view的实现
- 简单实现消息提示(小红点)
- Android BGABadgeView:新消息/未接来电/未读消息/新通知圆球红点提示(1)
- SeekBar实现实现进度提示随thum移动,自定义View
- 随想录:开发一流Android SDK
- @ResponseBody注解的作用
- eclipse搜索关键字
- 地图相关
- Hadoop/MapReduce移动平均:时间序列数据平均值
- 自定义view实现未读消息提示(小红点)
- IONIC3 input调用手机键盘搜索
- Linux实现SSH免密码登陆
- 【云星数据---Apache Flink实战系列(精品版)】:Apache Flink实战基础0016--IDEA搭建非maven管理的集成开发环境001
- java中string和int互相转化
- Linux压缩解压命令
- Makefile之 cc编译命令选项
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Nam
- JS——[]==[]