更新时间:2023-01-08 14:58:00
问题是adjustViewBounds
不会增加ImageView
的大小> 超出可绘制对象的自然尺寸.它只会缩小视图以保持纵横比;如果您提供 500x500 的图像而不是 50x50 的图像,这应该可以.
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.
如果您对实现此行为的位置感兴趣,请参阅 ImageView.java的onMeasure实现.
If you're interested in the spot where this behavior is implemented, see ImageView.java's onMeasure implementation.
一种解决方法是实现一个自定义 ImageView
来改变 onMeasure
中的这种行为.
One workaround is to implement a custom ImageView
that changes this behavior in onMeasure
.