ImageView: adjustViewBounds does not work with layout_height=“fill_parent”?

淺唱寂寞╮ 提交于 2019-12-03 05:21:28

This is a LinearLayout bug. If you look at forceUniformHeight in the source here. You can see that to handle sizing child views which supply match_parent as the height when the LinearLayout is set to wrap_content, the LinearLayout pretends to have an absolute height, recalculates the child height and then reuses the child width from the previous measure pass. Basically your image is calculating height and width unconstrained and getting default width and height, and then having height recalculated but being forced to use the old width. You will need to supply a height or override some View onMeasures

you can also put gravity to be centered on the linear layout

NOTE: that you should also have different images in drawables-hdpi/ldpi and mdpi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!