现在的位置: 首页 > 综合 > 正文

动态改变控件大小

2017年11月17日 ⁄ 综合 ⁄ 共 366字 ⁄ 字号 评论关闭

转自:http://blog.sina.com.cn/s/blog_62c194760100gtko.html

利用getLayoutParams()方法和setLayoutParams()方法。
三步曲:
1、首先利用getLayoutParams()方法,获取控件的LayoutParams。
eg:LayoutParams laParams=(LayoutParams)imageView.getLayoutParams();
2、设置该控件的layoutParams参数
eg:     laParams.height=200;
        laParams.width=100;
3、将修改好的layoutParams设置为该控件的layoutParams.
eg:imageView.setLayoutParams(laParams);

抱歉!评论已关闭.