Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 782
gutiory Avatar asked Sep 05 '11 18:09

gutiory


People also ask

How do I change the position of a button in linear layout?

You can set the android:layout_weight='1' and both buttons will share the screen equally(side by side) or if you want the extra space between them, you can place a button each in a linear layout and set the android:layout_gravity to left and right for each.


1 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.

like image 71
Shlublu Avatar answered Oct 11 '22 15:10

Shlublu