我创建了一个应用程序,它应该随机放置几个按钮(或图像视图),我传递最大值和最小值,然后从那里获取坐标。
问题是在4.2.2中编译是完美的,但我寻求在2.3.3中工作,因为我想在google play中分享我的应用程序。
我使用的是android 4.2.2。去做这个应用。
button.setX()和button.setY()
但是在Android2.3.3( API级别10 )中可以使用这些方法
你知道我怎样才能达到API级别10吗?
非常感谢!
发布于 2013-04-24 17:47:18
你应该看看这个答案:
https://stackoverflow.com/a/12195999/2140191
//The WRAP_CONTENT parameters can be replaced by an absolute width and height or the FILL_PARENT option)
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.leftMargin = 50; //Your X coordinate
params.topMargin = 60; //Your Y coordinate之后,使用以下命令将LayoutParams添加到按钮:
button.setLayoutParams(params);发布于 2013-04-24 17:27:32
试着使用
setTranslationX(float xVal)公共浮点getX ()
在API级别11中添加此视图的视觉x位置(以像素为单位)。这相当于translationX属性加上当前的left属性。
返回此视图的视觉x位置,以像素为单位。
https://stackoverflow.com/questions/16187508
复制相似问题