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是控件的名称。

 

posted @ 2016-04-22 14:59  某某璀  阅读(1217)  评论(0)    收藏  举报
levels of contents