gutiory
gutiory

Reputation: 1135

Exact position of a Button inside a Layout

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)?

Upvotes: 5

Views: 10894

Answers (3)

bradley4
bradley4

Reputation: 3938

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)

Upvotes: 0

Shlublu
Shlublu

Reputation: 11027

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.

Upvotes: 5

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

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.

Upvotes: 0

Related Questions