-1

画像があり、画面サイズに合わせて拡大したい。それが私のコードです:

 <ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:baselineAlignBottom="false"
    android:cropToPadding="false"
    android:maxWidth="@dimen/padding_small"
    android:src="@drawable/footerheader_bg" />

何が起こるかというと、imageViewフレームは実際に画面の左右に引き伸ばされていますが、その中の画像は以前と同じくらい小さいままです。画像はJPEGであり、Macを使用しています(該当する場合)。ありがとう!

4

3 に答える 3

3

アスペクト比がどうなっても構わない場合は、次の 2 つの方法のいずれかを使用できます。

android:layout_width="fill_parent"
android:layout_height="fill_content"
android:src="@drawable/footerheader_bg"
android:scaleType="fitXY"

また

android:layout_width="fill_parent"
android:layout_height="fill_content"
android:background="@drawable/footerheader_bg"

ただし、アスペクトが重要な場合は、これを試してください

android:layout_width="fill_parent"
android:layout_height="fill_content"
android:src="@drawable/footerheader_bg"
android:scaleType="fitCenter"
于 2012-07-16T10:22:13.620 に答える
1

これを変えるandroid:src="@drawable/footerheader_bg"

android:background="@drawable/footerheader_bg"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
于 2012-07-16T10:00:10.623 に答える
1

次の 2 つの選択肢があります。

1 )

android:src="@drawable/footerheader_bg"プロパティを追加し、プロパティを追加しますandroid:scaleType="fitXY"

2)プロパティを 削除し android:src="@drawable/footerheader_bg"、背景プロパティを使用しandroid:background="@drawable/footerheader_bg"ます。画像はデフォルトで引き伸ばされます。設定を忘れないでください:

android:layout_width="match_parent"
android:layout_height="match_content"
于 2012-07-16T10:04:50.620 に答える