我在 listView 中有一个 imageView。像这样设置:main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/listView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
图像.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
这很好用,用 http 请求从 url 填充许多图像。但是我对图像的大小有疑问。无论分辨率或大小,我都希望它们填满屏幕。尝试了不同的布局高度、宽度和比例类型,但无法正常工作。
第一张图是现在的样子,第二张图是我想要的样子。
编辑:尝试使用 scaleType="fitXY" 这给了我 100% 的宽度,但在较长的图像上的高度很差。