ImageView maxHeight不一致

问题描述 投票:0回答:2

我在RelativeLayout中有一个ImageView,定义了maxHeight。我正在使用Glide将图像加载到此ImageView中

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:background="@drawable/background">
<ImageView
    android:id="@+id/img_View_Pic"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:maxHeight="200dp"
    android:visibility="gone" />
</RelativeLayout>

首先,我看到Imageview高度正常工作,但如果我去另一个活动并回到此活动,相同的图像高度有时会进一步减少少于200dp

我不知道为什么会这样?任何帮助都会有所帮助。

android imageview android-imageview android-glide
2个回答
0
投票

除了android:maxHeight="200dp"属性之外,请尝试添加此属性,并告诉我这是否有用:

android:adjustViewBounds="true"

0
投票

我认为这个问题是因为最大限度,但我错了

相反,我发现问题出在Glide上,它在重新加载时改变了原始drawable的像素,结果我得到了不同大小的图像。

© www.soinside.com 2019 - 2024. All rights reserved.