图像拍摄在Android中的imageView中加倍空间

时间:2015-10-11 10:58:14

标签: android imageview

我在Imageview中放了一个图像,但它占用了两倍的空间。它下面的图像和textview之间存在很大差距。如何设置图像以使用图像的高度?

我的布局如下:

<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"

    android:gravity="center" android:padding="5dp" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/babyfa"

        android:scaleType="fitStart"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"


        android:text="@string/whatis"
    />

我附上了图片,红线代表了imageview正在拍摄的额外空间。请建议。Image

1 个答案:

答案 0 :(得分:1)

这很可能是由Rack::Test引起的。尝试从XML中删除它。有关不同android:scaletype="fitStart"属性的效果,请参见this helpful guidescaletype位于底部)。

修改:尝试同时设置fitStart。这有望强制ImageView保留图像的宽高比。