简体   繁体   English

Android为多种设备开发

[英]Android developing for multiple devices

I have only ever programmed for the iphone and back then there was just one size and I did not have to worry about different screen resolutions and size. 我只为iphone编程,那时只有一个尺寸,而我不必担心屏幕分辨率和尺寸不同。 How in the world do I go about supporting multiple devices in android development? 我该如何在android开发中支持多个设备? I have absolutely no clue and i've done some googling but it's not getting through to me. 我完全不知道,我已经进行了一些谷歌搜索,但没有成功。

Say I want a 15x25 grid of 32x32 tiles on my Nexus One. 假设我要在Nexus One上使用15x25的32x32像素网格。 Well, how would I maintain the 15x25 oh a G1 or some other device? 好吧,我该如何维护G1或其他设备的15x25分辨率?

This page has everything you need to know. 此页面包含您需要了解的所有内容。

Obviously, you have several choices: You can scale everything so it looks the same, with just higher-quality graphics on a higher-res screen (for that, you can provide multiple versions of your images, see the link to see how). 显然,您有多种选择:您可以缩放所有内容,使其看起来相同,在更高分辨率的屏幕上仅显示高质量的图形(为此,您可以提供图像的多个版本,请参见链接以了解操作方法)。 Or, if it makes sense, you can get the physical screen dimensions and adjust your code accordingly, ie you take the width, divide by a certain number, and that's your number of tiles. 或者,如果可以的话,您可以获取物理屏幕尺寸并相应地调整代码,即,您将宽度乘以一定数量,得到的就是瓷砖的数量。 In most cases though, you choose the former approach. 但是,在大多数情况下,您选择前一种方法。

Android supports a unit of measurement that is device-independent. Android支持与设备无关的度量单位。 That will help you make everything look the same. 这将帮助您使所有内容看起来都一样。

In order to support multiple screens you will have to use DIPs instead of Pixels. 为了支持多个屏幕,您将必须使用DIP而不是像素。 This document is a must-read for any android developer: 本文档是所有android开发人员必读的文档:

Supporting Multiple Screens 支持多屏

thats easy. 这很容易。 first don't worry! 首先不用担心! :) Second, get width and height of your screen and divide it to any number of tiles you want. :)其次,获取屏幕的宽度和高度,并将其划分为所需的任意数量的图块。 this is the procedure that I did to develop a game for all types of screen sizes. 这是我为所有类型的屏幕尺寸开发游戏的过程。 see here: http://www.mobilesoft.asia/?p=47#more-47 看到这里: http : //www.mobilesoft.asia/?p=47#more-47

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM