Android实现消息未读气泡,自适应数值长度

在drawable文件夹创建文件red_circle.xml (corners里面的数值要大于控件的高度)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/doc_type_red" />
    <corners
        android:bottomLeftRadius="36dp"
        android:bottomRightRadius="36dp"
        android:topLeftRadius="36dp"
        android:topRightRadius="36dp" />
</shape>

在布局文件中添加TextView (要设置高度与最小宽度,宽度要自适应)

<TextView
android:id="@+id/t_test"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:background="@drawable/red_rounded_recatangle"
android:gravity="center"
android:minWidth="10dp"
android:text="123456"
android:textColor="@color/white"
android:textSize="10sp" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值