以编程方式设置 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
:
imageView.getLayoutParams().height = 20;
重要.如果您在布局已经布局"之后设置高度,请确保您还调用:
Important. If you're setting the height after the layout has already been 'laid out', make sure you also call:
imageView.requestLayout();
这篇关于以编程方式设置 ImageView 的宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文