简体   繁体   English

适用于不同屏幕尺寸的Android应用程序

[英]Android application for different screen sizes

As i new in android development i just want to know is there any way to develop Android application for different screen sizes ? 当我刚接触android开发时,我只是想知道有什么方法可以针对不同屏幕尺寸开发Android应用程序?

help me. 帮我。

Thank you in advance 先感谢您

Just add this in your project. 只需将其添加到您的项目中即可。

res/values/main.xml res / values / main.xml

res/values-sw600dp/main.xml -> 7+ inches res / values-sw600dp / main.xml-> 7英寸以上

res/values-sw720dp/main.xml -> 10+ inches Create this folder and just copy your xml file in all the folders. res / values-sw720dp / main.xml-> 10英寸以上创建此文件夹,然后将xml文件复制到所有文件夹中。

Put your main.xml in those folders: 将您的main.xml放在以下文件夹中:

 res/values/   //your default values (in your case for phones)

 res/values-large/    //specfic values for relatively big screens

 res/values-xlarge/    //specific values for really big screens

large: Screens that are of similar size to a medium-density VGA screen. 大:与中密度VGA屏幕尺寸相似的屏幕。 The minimum layout size for a large screen is approximately 480x640 dp units. 大屏幕的最小布局大小约为480x640 dp单位。 Examples are VGA and WVGA medium density screens. 例如VGA和WVGA中密度屏幕。

xlarge: Screens that are considerably larger than the traditional medium-density HVGA screen. xlarge:比传统的中密度HVGA屏幕大得多的屏幕。 The minimum layout size for an xlarge screen is approximately 720x960 dp units. xlarge屏幕的最小布局大小约为720x960 dp单位。 In most cases, devices with extra large screens would be too large to carry in a pocket and would most likely be tablet-style devices. 在大多数情况下,具有超大屏幕的设备太大而无法装在口袋中,并且很可能是平板电脑式设备。 Added in API level 9. 在API级别9中添加。

see more infos here: http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes 在此处查看更多信息: http : //developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes

Google provide good article how to support multiple screens 谷歌提供的好文章如何支持多屏

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

General advices: 一般建议:

use layout - for for mobile phone layouts 使用布局-用于手机布局
use layout-sw600dp folder for 7inch tablets layouts 将layout-sw600dp文件夹用于7inch平板电脑布局
use layout-sw720dp folder for 10inch tablets layouts 将layout-sw720dp文件夹用于10inch平板电脑布局

use dimens.xml in values folder to define dimentions for your UI 在values文件夹中使用dimens.xml为您的UI定义尺寸
you also can use values-sw600dp and values-sw720dp with its own dimens.xml file for 7 and 10 inch tablets 您还可以将values-sw600dp和values-sw720dp与自己的dimens.xml文件一起使用,用于7和10英寸平板电脑

Writing apps for multiple devices requires one to have good knowledge on basic concepts like : what is Dpi, Screen density , Orientation etc. 为多种设备编写应用程序需要具有一些基本概念的知识,例如:什么是Dpi,屏幕密度,方向等。

Article below is good place to start for: 下面的文章是开始的好地方:

Supporting Multiple Screens http://developer.android.com/guide/practices/screens_support.html 支持多个屏幕http://developer.android.com/guide/practices/screens_support.html

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

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