我在RelativeLayout里面有一个ImageView。ImageView的源是一个.png文件。问题在于,当在不同分辨率的设备上测试时,Android没有对图像进行缩放。我在Android文档中读到,Android会自动缩放图像以填充屏幕,但这并没有发生。可能出了什么问题?我是Android的新手,如果这个问题很蠢的话请见谅,我已经搜索了很多但是找不到解决方案。
编辑:XML代码:
编辑: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>
match_parent
。 - Pragnani