0

I created an app that should put a few buttons ( or imageview) at random, I pass the maximum and minimum values ​​and from there take the coordinates.

The problem is that in 4.2.2 compilation is perfect, but I seek to work for 2.3.3 because I want to share my application in google play.

i use android 4.2.2. to do the app.

button.setX() and button.setY()

but in android 2.3.3 ( API level 10 ) can use the methods

Do you know how could I in API level 10?

Thank you very much!

CristianCV
  • 342
  • 1
  • 5
  • 17

2 Answers2

2

You should look at this answer:

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

After that add the LayoutParams to the button with:

button.setLayoutParams(params);
Community
  • 1
  • 1
D. Wonnink
  • 306
  • 4
  • 19
0

try to use

setTranslationX(float xVal)

public float getX ()

Added in API level 11 The visual x position of this view, in pixels. This is equivalent to the translationX property plus the current left property.

Returns The visual x position of this view, in pixels.

umesh
  • 1,148
  • 1
  • 12
  • 25
  • i want do it in API level 10, api level 11 is for android 3.0 and the most android devices have a smaller version of the three – CristianCV Apr 24 '13 at 09:36