1

我在 ImageView 中有一个非常宽的图像,因为我将它用作动画背景。如何显示图片以使其高度填满整个父级,并且显示宽度与屏幕宽度一样多?

我试着用这段代码做这个:

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

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

</RelativeLayout>

但它不起作用。它只是在屏幕内显示整个图片,将其宽度调整为屏幕的宽度。我错在哪里?

4

1 回答 1

1

你有没有尝试过这样的事情:

如何显示图像的一部分?

或者你可以使用安卓缩放

 Use android:scaleType="centerInside"
于 2013-07-24T22:03:57.103 回答