0

私は大きな画像myImage.pngを持っています(その薄暗いのは1536 x 784です):

図1

この画像をレイアウトの下部に配置し、均一に拡大縮小して幅に合わせます。

図2

レイアウトは

<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" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/myImage"
        android:adjustViewBounds="true"
        android:layout_alignParentBottom="true"
        android:scaleType="fitCenter" >
    </ImageView>

</RelativeLayout>

layout_width、、layout_heightの組み合わせadjustViewBoundsを何十回も試しましたがscaleType、何も役に立ちませんでした。常に次のようになります。

図3

お願い助けて。

4

3 に答える 3

2

誰かが言うように、backgroundの代わりにsrcを使用してください:

<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" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/myImage"
        android:adjustViewBounds="true"
        android:layout_alignParentBottom="true"
        android:scaleType="fitCenter" >
    </ImageView>

</RelativeLayout>
于 2012-10-23T14:44:18.503 に答える
1

ImageViewを使用しています。ImageViewsは、src属性を使用して、使用する画像を示し、scaleTypeを適用します。

背景は、名前が示すように、単に背景属性であり、その背景全体に表示されるように作られています。

于 2012-10-23T14:39:20.173 に答える
0

これを試して:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/myImage"
    android:adjustViewBounds="true"
    android:layout_alignParentBottom="true"
    android:scaleType="fitcenter" >
</ImageView>
于 2012-10-23T14:40:09.413 に答える