我有一个相对论层内的图像视图。ImageView的源文件是一个.png文件。问题是,当在不同分辨率的设备上测试时,android没有放大或缩小图像。我在android文档中看到,android会自动向上或向下缩放图像以填充屏幕,但这并没有发生。有什么问题吗?我是android新手,抱歉,如果这个问题是愚蠢的,我搜索了很多,但找不到解决方案。
编辑:XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >

<ImageView
        android:id="@+id/imageview1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:layout_centerInParent="true"
        android:clickable="false"
        android:scaleType="fitXY"
        android:contentDescription="@string/p"

        android:src="@drawable/example" />
</RelativeLayout>

编辑2:需要拉伸的XML布局:
    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:theme="@android:style/Theme.Black.NoTitleBar"
    android:gravity="center">

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:clickable="false"

        android:contentDescription="@string/p"

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



    <ImageView

        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:layout_alignParentLeft="true"
        android:contentDescription="@string/p"

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

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="33dp"
        android:layout_marginRight="19dp"
        android:text="@string/press_to_update" />

    <ImageView
        android:id="@+id/imageView9"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView2"
        android:clickable="false"
              android:contentDescription="@string/p"

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

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"

        android:layout_below="@+id/imageView9"
        android:clickable="false"
        android:contentDescription="@string/p"

        android:src="@drawable/base" />
    </RelativeLayout>

最佳答案

在布局中使用android:scaleType="fitXY"
编辑
如果想让图像占据整个屏幕,请使用

    android:layout_width="match_parent"
    android:layout_height="match_parent"

07-24 09:49
查看更多