相信很多人都遇到过在一个控件上显示IM消息提示的功能吧(红点或者是数字)
还有就是约束布局实现(ConstraintLayout)
im_hint.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<TextView
android:id="@+id/projectDynamicTV"
android:layout_width="@dimen/name_dp60"
android:layout_height="@dimen/name_dp30"
android:background="@color/color50A"
android:gravity="center"
android:text="消息红点"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dot_red"
app:layout_constraintBottom_toTopOf="@id/projectDynamicTV"
app:layout_constraintLeft_toRightOf="@id/projectDynamicTV"
app:layout_constraintRight_toRightOf="@id/projectDynamicTV"
app:layout_constraintTop_toTopOf="@id/projectDynamicTV" />
</android.support.constraint.ConstraintLayout>
复制代码
dot_red.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#E95548"/>
<size
android:width="9dp"
android:height="9dp"></size>
</shape>
复制代码
实现的方法很多,以上只是我的实现方式,希望帮到你