设置ImageView的宽度和高度编程? [英] Set ImageView width and height programmatically?
本文介绍了设置ImageView的宽度和高度编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置的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()
这篇关于设置ImageView的宽度和高度编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文