Android开发右上角数字红点效果

Android开发右上角数字红点效果

往往需要控件右上角有个数字红点提醒用户

一、思路:

就是用TextView显示数字红点,慢慢调位置

二、效果图:

在这里插入图片描述

三、关键代码:
 <ImageView
        android:id="@+id/aiv_img"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:background="@android:color/transparent"
        android:src="@mipmap/ic_system_notify"
        android:scaleType="centerCrop"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        />


    <TextView
        android:id="@+id/tv_unread_count"
        android:layout_width="wrap_content"
        android:layout_height="16dp"
        android:includeFontPadding="false"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        app:layout_constraintRight_toRightOf="@id/aiv_img"
        app:layout_constraintTop_toTopOf="@id/aiv_img"
        android:layout_marginRight="-2dp"
        android:layout_marginTop="-2dp"
        android:background="@drawable/aliwx_unread_hint"
        android:gravity="center"
        android:textColor="@android:color/white"
        android:textSize="10sp"
        android:text="9" />
四、项目demo源码结构图:

在这里插入图片描述有问题或者需要完整源码的私信我

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值