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)?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With