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

后端 未结 2 603
醉话见心
醉话见心 2021-02-07 11:18

I\'m trying to place in single row the EditText with the ImageView on the left. But I can\'t get the image to be scaled properly to match the height of

相关标签:
2条回答
  • 2021-02-07 11:47

    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

    0 讨论(0)
  • 2021-02-07 11:48

    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

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