开发者

positioning items in android dev

开发者 https://www.devze.com 2023-02-17 04:32 出处:网络
Hi I\'m totaly new to android, I\'m looking for a very very very simple thing that in every possible dev env is straight forward, except apparently android.

Hi I'm totaly new to android, I'm looking for a very very very simple thing that in every possible dev env is straight forward, except apparently android. how the hell do I set X and Y for every UI object that I wanna place there. For example i开发者_如何学Gon xml i have LinearView or RelativeView and in them I have Button, I'm looking for a way to set this button position on the screen using Y and Y, should be pretty straight forward thingy, I mean in iOS dev you just do CGRectMake(x,y,width,height) and there you go. What is the equivalent in android dev?

thanks


From Android Developers

Android is designed to run on a variety of devices that offer a range of screen sizes and resolutions

So, unless you are targeting only one specific Android device, you'd not want to use absolute coordinates, as, for exemple, x=300px on one device can mean a reference outside the screen on another device(a small-screen one).
Instead, you learn to use just relative positions as top, bottom, below, etc, that works on every device.

Try to do the Hello Views tutorials first, in order to better understand how things are working for Android.


Please use layout_x and layout_y with a AbsoluteLayout in your layout xml.

0

精彩评论

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