动态地改变机器人的ImageView的位置 [英] changing the position of ImageView dynamically in android
本文介绍了动态地改变机器人的ImageView的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有
我需要动态和IAM改变的ImageView的位置使用以下code
I need to change the position of a ImageView dynamically and iam using the following code
int x=100,y=100;
RelativeLayout.LayoutParams mparam = new RelativeLayout.LayoutParams((int)(LayoutParams.FILL_PARENT),(int)(LayoutParams.FILL_PARENT));
mparam.topMargin=x;
mparam.leftMargin=y;
ball.setLayoutParams(mparam);
x+=100;
y+=100;
但我没有得到任何改变。
but i didnt get any change.
这可能吗?而如何?
推荐答案
您可以拨打您的View setPadding。所以,在你的code(其中的方式,你应该把在code座!),只需添加一个调用此方法:
You can call setPadding on your View. So, in your code (which by the way you should put in a code block!), just add a call to this method:
int x=100,y=100;
LayoutParams mparam = new LayoutParams((int)(LayoutParams.FILL_PARENT),(int) (LayoutParams.FILL_PARENT));
ball.setLayoutParams(mparam);
ball.setPadding(x,y,0,0);
x+=100; y+=100;
ball.setPadding(x,y,0,0);
这篇关于动态地改变机器人的ImageView的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文