微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android图像视图大小不随图像缩放

我有以下 android布局:
<?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)

有没有办法让图像视图的大小与图像的缩放大小完全匹配?

解决方法

它看起来类似于这个问题: Android ImageView size not scaling with source image,解决方案是将android:adjustViewBounds =“true”添加到ImageView

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐