I would like to place some buttons—each one at one specific coordinates where I know and specify the x and y position. Is it possible to place buttons at specific coordinates? And if it is possible, is that correct (Android programmatically speaking)?
3 Answers
Yes, you can absolutely do that. The only problem is that it is "dangerous" to specify an absolute position in pixels because another device may have (is likely to have, in fact) a different screen configuration.
This official tutorial explains how to design a layout that correspond to your wishes without being dependant of the screen configuration.
But if you absolutely need to specify the position of a widget in absolute pixels, you can either do it this way or that way.
-
1Thanks a lot. You're right. I'm affraid of using absolute position in pixels because I would like to test my application in diferent resolutions. I'll watch the tutorial in deep for taking a decision of how I'll implement my solution. I'll explain here for finishing the post. – gutiory Sep 05 '11 at 18:23
Another post has the same question more or less, this link can help you i think
Android: Change absolute position of a view programmatically
It can be applied to any view, in your case buttons too.

- 1
- 1

- 28,931
- 15
- 65
- 69
This links should help. and yes x and y coordinates are terms used in Android, but you may want to trying using linearlayouts and relativelayout first.
Android: how to place a button at an x,y position over top of Canvas
How to place views in a specific location (x, y coordinates)