RelativeLayout is a great option.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:scaleType="centerCrop" android:src="@drawable/iconImage" /> <ImageView android:id="@+id/badge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/icon" android:layout_alignTop="@+id/icon" android:src="@drawable/badge" />
If you really need an icon with a dynamic number / text, you can make a second ImageView
a TextView
(or a ViewGroup
, such as LinearLayout
or RelativeLayout
), and give it a background to cut and set the text according to what you want.
source share