Search code examples
androidimageviewandroid-imageviewandroid-glide

ImageView maxHeight is not consistent


I have an ImageView inside an RelativeLayout with maxHeight defined. I am loading the image into this ImageView using Glide

<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>

First I see the Imageview height is correctly working, but if I go to another activity and come back to this activity the same image height further reduces less than 200dp sometimes

I have no clue why is it happening ? Any help would be helpful.


Solution

  • I thought the issue was because of maxheight but I was wrong

    Instead I found the issue was with Glide, it was changing the original drawable's pixel on reload as a result I was getting different sized image.