设置ImageView的宽度和高度编程?宽度、高度、ImageView

2023-09-11 12:12:10 作者:彩虹少年、爱发光

如何设置的ImageView 的宽度和高度编程?

How can I set an ImageView's width and height programmatically?

推荐答案

这可能为时已晚,但为他人着想谁拥有了同样的问题,要设置的ImageView的高度:

It may be too late but for the sake of others who have the same problem, to set the height of the ImageView:

image_view.getLayoutParams().height = 20;

希望这有助于。

Hope this helps.

重要如果您正在设置的高度后布局已经布局,请确保您还要求:

Important. If you're setting the height after the layout has already been 'laid out', make sure you also call:

image_view.requestLayout()