1

背景画像を含む画像ビューがあり、ImageView サイズに対して中央に配置された前景の「画像」として、テキストビューの上に ImageView を配置します。

        selectedImageView = (ImageView) view.findViewById(R.id.selectedImage);
        selectedImageView.setBackgroundResource(R.drawable.back_item);
        selectedImageView.setImageResource(R.drawable.icon_alarm);

上記のコードは、前景の画像を ImageView のサイズに引き伸ばしますが、前景を背景の円の「内側」に配置したいと考えています。

パディングが使用されている場合、異なる画面サイズで問題が発生する可能性があります。

前景画像は、ImageView サイズの高さと幅の 50% にスケーリングする必要があり、textview は前景画像の下に配置する必要があります。

黒い外側の四角: 画像ビューの境界、黒い円: 背景画像、読み取り四角: 前景画像、青い長方形: 前景テキスト

黒い外側の四角: 画像ビューの境界、黒い円: 背景画像、読み取り四角: 前景画像、青い長方形: 前景テキスト

4

1 に答える 1

0

これは非常に重いですが、このレイアウトを使用するとうまくいくはずです:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"

        android:src="@drawable/ic_action_search" />

    <ImageView
        android:id="@+id/foreground"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

それが役立つことを願っています

于 2013-09-13T18:16:28.540 に答える