Android ImageView size not scaling with source image

后端 未结 4 1392
心在旅途
心在旅途 2020-12-02 05:16

I have a few ImageViews inside a LinearLayout. I need to scale down the ImageViews so that they maintain their aspect ratios whilst fitting inside the LinearLayout vertical

相关标签:
4条回答
  • 2020-12-02 05:45

    Yes, my solution for this, was:

    android:scaleType="fitXY"
    
    0 讨论(0)
  • 2020-12-02 05:46

    Strangely android:layout_height="fill_parent" and android:adjustViewBounds="true" didn't help. The problem I had is image was getting displayed, but with block row on top and black row on bottom of image. Setting scale type to "centerCrop" helped me. I guess, the reason being my image size was small.

    0 讨论(0)
  • 2020-12-02 06:04

    What about changing your ImageViews to use android:layout_height="fill_parent"?

    Edit - took me a while to find, but looking at the source helped me pinpoint adjustViewBounds. You might want to try adding android:adjustViewBounds="true" to your ImageViews. Surprisingly, this defaults to false.

    0 讨论(0)
  • 2020-12-02 06:08

    I had similar problem and my solution was to set android:scaleType="fitEnd" attribute of ImageView in XML layout file.

    0 讨论(0)
提交回复
热议问题