7

下記を参照してください:

iPhoneバッジ

絶対レイアウトを使用してみましたが、非推奨です。私はあなたの助けに感謝します、ありがとう。

4

2 に答える 2

16

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番目のバッジImageViewTextViewまたはなどViewGroup)を作成し、背景を描画可能にして、テキストを必要なものに設定できます。LinearLayoutRelativeLayout

于 2012-06-18T19:58:35.240 に答える
8

github のViewBadgerプロジェクトを見てください(ただし、Android アプリで他のプラットフォームの UI 要素をコピーしようとしないでください)。

于 2012-06-18T19:57:33.810 に答える