Android开发:在布局里移动ImageView控件
在做一个app时碰到需要移动一个图案的位置,查了一上午资料都没找到demo,自己写一个吧
1 RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 2 RelativeLayout.LayoutParams.WRAP_CONTENT); 3 4 lp.setMargins(left, top, right, bottom); 5 xImageView.setLayoutParams(lp);
习惯了在xml文件中写死margins属性,现在需要动态修改布局就没辙了。。
若不需要设置与某边距的距离,置0就可以了,xImageView是控件的名称。
作者:pngcui
博客园:http://www.cnblogs.com/pngcui/
github:https://github.com/pngcui
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明。

浙公网安备 33010602011771号