开发者

Exact position of a Button inside a Layout

I would like to place some but开发者_Python百科tons—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)?


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.


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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜