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

后端 未结 2 605
醉话见心
醉话见心 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

提交回复
热议问题