0

相対レイアウトに ImageButton を追加しました。xml コードは

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomePageActivity" >

<ImageButton
    android:id="@+id/imageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="132dp"
    android:background="@null"
    android:scaleType="fitXY"
    android:src="@drawable/book" />

</RelativeLayout>

幅と高さがwrap_contentであるため、画像は鮮明ですが、次のように幅と高さを大きく指定すると:

android:layout_width="80dp"
android:layout_height="80dp"

次に、AVD で実行すると、画像ボタンが明瞭さを失います。解決策はありますか??

4

1 に答える 1

1

デフォルトでは、 ImageView/ImageButtonは画像を中央に合わせて拡大/縮小します。

を使用して変更できますandroid:scaleType = "center"。これにより、画像は元のサイズを維持し、中央に配置されます。

画像がオブジェクトの画像ではなく、単なる長方形である場合は、9 パッチのドローアブルに変換します。

于 2013-02-04T14:51:03.680 に答える