安卓图片视图大小不随图片缩放

7
我有以下的安卓布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainTopLevel"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
    <ImageView
        android:id="@+id/orbitImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:scaleType="fitStart"
        android:src="@drawable/earthorbit"
        android:padding="0dp"
        android:background="@android:color/white"
    />
    <TextView
        android:id="@+id/positionDesc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minHeight="40dp"
        android:layout_below="@id/orbitImage"
        android:text="should appear below image"
   />
</RelativeLayout>

图像会缩小很多,但由于保持了宽高比,因此只占屏幕的上半部分。
问题在于图像视图本身具有原始高度,这需要整个屏幕来显示,文本从未显示出来。
(所以原始图像大约为620 X 430,缩放后的图像大约为250 X 200,但图像视图大约为250 X 430)
有没有办法让图像视图的大小完全匹配图像的缩放大小?
2个回答

11

你是救星啊!真希望我能给你投1000个赞。我之前真的很沮丧。如果还有其他人在找,这个方法同样适用于GridView。 - RiddlerDev

0

由于资源中的图像文件大小是固定的,因此您应该能够在ImageView上固定高度:android:layout_height="200dp"


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接