Android图片上显示气泡消息

jopen 10年前

   经常需要在一个图片上面显示一个气泡,在气泡上面显示消息的数量。这里提供一种方法,直接设置textview的背景色,并且设置textview的文本信息。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:tools="http://schemas.android.com/tools"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:background="@drawable/ic_launcher"      tools:context=".MainActivity" >        <TextView          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_gravity="right|bottom"          android:layout_marginLeft="40dip"          android:background="@drawable/red_circle"          android:gravity="center"          android:text="1"          android:textSize="12dip" />    </LinearLayout>

实现效果:

Android图片上显示气泡消息