在Android开发人员中定位项目 [英] positioning items in android dev

查看:90
本文介绍了在Android开发人员中定位项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好
我是android的新手,
我在寻找一个非常非常简单的东西,在所有可能的开发环境中,它都是直截了当的,但显然不是android。
我该如何为要放置的每个UI对象设置X和Y。
例如在xml中,我有LinearView或RelativeView,在它们中有Button,我正在寻找一种使用Y和Y来设置此按钮在屏幕上的位置的方法,应该很简单,我的意思是iOS开发人员只需执行CGRectMake(x,y,width,height)即可。
android dev中的等效项是什么?

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

谢谢

推荐答案

来自 Android开发人员


Android旨在在
种设备上运行,这些设备提供范围为
的屏幕尺寸和分辨率

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

因此,除非您仅针对一台特定的Android设备,否则您将不希望使用绝对坐标,例如,在一台设备上x = 300px可能意味着在

相反,您学会了仅使用相对位置作为上,下,下等位置,该位置适用于每台设备。

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.

尝试执行Hello视图教程首先,为了更好地了解Android的运行方式。

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

这篇关于在Android开发人员中定位项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆