【问题标题】:ImageView doesn't fill entire widthImageView 没有填满整个宽度
【发布时间】:2012-08-03 00:44:13
【问题描述】:

我正在为多个设备开发一个 Android 2.2 应用程序,但我遇到了图像问题。

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:contentDescription="@string/layout_empty"
            android:src="@drawable/faqs" />

    </ScrollView>

这是我在平板设备上看到的:

在我的 HTC Desire 上看起来很完美。

怎么了?

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    android:scaleType="fitXY" 添加到您的 ImageView

    【讨论】:

    • 优秀。现在,只是为了理解,不就是这条线的功能吗? android:layout_width="match_parent"
    • 但它没有保持纵横比。即使使用 android:adjustViewBounds="true" 参数!
    【解决方案2】:

    查看接受的答案here。需要设置image view的layout_height为fill_parent

    【讨论】: