ImageView adjustViewBounds not working

后端 未结 5 1586
长发绾君心
长发绾君心 2020-12-01 01:27

I have an ImageView with android:layout_width=100dp, android:layout_height=wrap_content and android:adjustViewBounds=true

It\'

5条回答
  •  一个人的身影
    2020-12-01 02:14

    The issue is that adjustViewBounds will not increase the size of the ImageView beyond the natural dimensions of the drawable. It will only shrink the view to maintain aspect ratio; if you provide a 500x500 image instead of a 50x50 image, this should work.

    If you're interested in the spot where this behavior is implemented, see ImageView.java's onMeasure implementation.

    One workaround is to implement a custom ImageView that changes this behavior in onMeasure.

提交回复
热议问题