下記を参照してください:
絶対レイアウトを使用してみましたが、非推奨です。私はあなたの助けに感謝します、ありがとう。
RelativeLayoutは優れたオプションです。
<?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" />
動的な数字/テキストのバッジが実際に必要な場合は、2番目のバッジImageView
(TextView
またはなどViewGroup
)を作成し、背景を描画可能にして、テキストを必要なものに設定できます。LinearLayout
RelativeLayout
github のViewBadgerプロジェクトを見てください(ただし、Android アプリで他のプラットフォームの UI 要素をコピーしようとしないでください)。