应用程序框架,支持多屏 [英] Application Skeleton to support multiple screen

查看:193
本文介绍了应用程序框架,支持多屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我们所知道的Andr​​oid即将与具有不同的各种设备 功能,分辨率和屏幕尺寸等等,同时开发支持的应用程序 多(大,小)的屏幕没有大小和布局的障碍。

As we know Android coming with various device which having different Features, Resolution and Screen-size so while developing an Application which support multiple(small and big) screen there is an obstacle of size and layout.

这导致了的的屏幕尺寸,分辨率和干粉吸入器的不同组合,并设计和开发Android设备时产生相当大的挑战。而其他一些制造商(非安卓)有不同的分辨率和DPI,它们具有相同的屏幕尺寸和决议遵循同样的纵横比。因此,图像可以被创建,以适应非Android设备。

This leads to different combinations of screen sizes, resolutions and DPIs and creates quite a challenge when designing and developing for Android devices. While some other Manufacturer(non Android) have different resolutions and DPI, they share the same screen size and the resolutions follow the same aspect ratio. Therefore, an image can be created to fit the non Android devices.

我的问题是,是否有合适的流量或架构,应该遵循以满足要求?

My question is that is there a proper flow or architecture that one should follow to meet the requirement?

记住,我们确实有不同的药片和解决。

我知道, Android开发 包含此信息,但我鉴于距离实现。

I'm aware that Android Developer contains this information but my view is from implementation.

这是我的知识,我的理解是,Android的设计图形,即使程序员必须知道的设计理念。

From my knowledge what I understood is that for designing Android graphics even Programmer must know the designing concept.

推荐答案

最后创建了一个结构,它处理的布局和图标多屏。

Finally created a structure which handle layouts and icon for multiple screen.

安卓可以推广设备显示为基于两个参数类:

Android generalises device displays into categories based on two parameters:

  • 屏幕尺寸,显示的物理尺寸(对角线测量)
  • 在屏幕像素密度,显示屏的物理像素密度(像素每英寸,或PPI)`

要确定屏幕尺寸和放大器;密度迅速,请安装什么是我的尺寸的应用程序Android系统。

To determine screen size & density quickly, please install "What's my Size" app for Android.

屏幕尺寸

安卓定义了四种广义的屏幕尺寸:

Android defines four generalised screen sizes:

 Qualifier           Size

 small               ~3 inches (approx) 
 normal              ~4 inches (approx) 
 large               Exceeds 4 inches    
 xlarge              Exceeds 7 inches  

  • 大多数手机被(对角线大致3〜4英寸)分类为小的或正常的。但现在,有很多手机与大屏幕,如银河S4,HTC一,的Xperiaž
  • 在一个小的平板电脑,如三星Galaxy Tab被归类为大(大于4英寸)
  • 超大适用于大型的设备,例如大粒
  • 安卓定义了四种广义的屏幕密度:

    Android defines four generalised screen densities:

     Qualifier         Description         Nominal value
    
     ldpi              low density          120 ppi
     mdpi              medium density       160 ppi
     hdpi              high density         240 ppi
     xhdpi             extra high density   320 ppi
    

    通常情况下:

    Typically:

    • 在屏幕大小对你的应用程序布局最具影响力
    • 在屏幕像素密度对图像和图形资源,最具影响力的

    据上市这里设备屏幕的百分比差异

    It is listed here the percentage difference of device screen

    • Ldpi- 75%
    • Mdpi- 100(根据Android开发者网站的基础)%
    • Hdpi- 150%
    • XHdpi- 200%

    不过,我们知道现在大部分设备即将与 480X800 的,所以我认为这是基于设备的,所以我们的新的计算会喜欢这个

    But as we know now most of device coming with 480X800 so I'm consider this as based device, so our new calculation will like this

    • Ldpi- 50%
    • Mdpi- 66.67%
    • Hdpi- 100%
    • XHdpi- 133.33%

    这意味着第一个图标,并设计将用于创建的 480X800 的唯一,然后休息的人(即LDPI,MDPI,Xhdpi)。

    which means that first icon and design will be created for 480X800 only and then for rest ones(i.e. Ldpi, Mdpi, Xhdpi).

    有哪些是常见的颜色和形状(无形状复杂,没有曲线),所有的布局,并必须统一图像,以便为这种我们正在创建图像 9patch 其中待放置在可拉伸(无后缀)的文件夹。要创建9Patch图像您可以使用 DrawNinePatch 或的 BetterNinePatch

    There are images which are common for all layout and must uniform in color and shape(no complex shape, no curve) so for this kind of image we are creating 9patch which to be put in "drawable(no-suffix)" folder. To create 9Patch image you can either use DrawNinePatch or BetterNinePatch

    现在只是基于Android的标准重新命名您的图片,并与华电国际完成您的应用程序,然后只取​​绘制 - 华电国际文件夹,然后打开的 Adode的Photoshop 的(推荐) 创建操作多个大小(只是按百分比率改变大小),一旦行动为各种规模的创建,然后就去做 批量自动化 并给源(绘制,华电国际)和目的地(绘制-LDPI,绘制,MDPI,绘制-xdpi)。

    Now just rename your images based on Android's standards and complete your application with hdpi and then just take drawable-hdpi folder and Open Adode Photoshop(recommended) create Action of multiple size(just change the size according to percentage ratio) once Action created for all size then just do Batch Automate and give source(drawable-hdpi) and destination(drawable-ldpi, drawable-mdpi, drawable-xdpi).

    我坚持让你用Photoshop,因为它会自动调整你的行为与形象,多了一个加点的原因是,你不必重命名文件(这将分配相同的名称,原来的一个)。

    The reason I insist you to use Photoshop because it will resize automatically your image with Actions and one more plus point is that you need not to rename the file(it will assign same name as original one).

    一旦你完成了创建所有图像,刷新您的项目并对其进行测试。

    once you completed with creation of all images, refresh your project and test it.

    有时可能是支持屏幕(xhdpi,华电国际,MDPI)的布局可能会得到削减在小屏幕(LDPI),所以处理这个刚创建单独的布局文件夹(布局小)为它添加可能性滚动型(大部分)。这就是它。

    Sometimes there may be possibility that the layout which support screen(xhdpi, hdpi, mdpi) may be get cut in small screen(ldpi) so for handling this just create separate Layout folder(layout-small) for it and add ScrollView(mostly). Thats it.

    片剂分为两种尺寸

    1. 7(1024×(600-48(导航栏)))= 1024X552(绘制大型)
    2. 10(1280X(800-48(导航栏)))= 1280X752(绘制-XLARGE)

    在此,我们需要创建图像为屏幕,只是把它们相应的

    In this we need to create image for both the screen and just put them accordingly

    所以,一切的一切,我们将这个文件夹在我们的应用程序,以支持多个屏幕。

    So all in all we will have this folder in our application to support multiple screen.

    drawable
    drawable-ldpi
    drawable-mdpi
    drawable-hdpi
    drawable-xhdpi
    drawable-large
    drawable-xlarge
    

    将与的屏幕尺寸和屏幕像素密度

    drawable-large-ldpi
    drawable-large-mdpi
    drawable-large-hdpi
    drawable-large-xhdpi
    

    详细限定词屏幕像素密度和版

    drawable-ldpi-v11
    drawable-mdpi-v11
    drawable-hdpi-v11
    drawable-xhdpi-v11
    

    多限定词屏幕尺寸和版

    drawable-large-v11
    drawable-xlarge-v11
    

    多限定词最小宽度的概念(SW)

     drawable-sw???dp
    

    此外更在Android的V3.0蜂窝他们推出了新概念SW(最小宽度),其中设备被归类为屏幕的宽度,所以如果我们要创建一个文件夹名为绘制-sw360dp 然后将设备与720dp(宽度或高度)将使用的资源从该文件夹。

    Further more in Android V3.0 Honeycomb they introduced new concept of SW(smallest width) in which device are categorized into screen width, so if we are creating a folder named drawable-sw360dp then the device with 720dp(either width or height) will use resource from the this folder.

    例如,找到三星Galaxy S3 DP 以后缀为绘制-SW?DP
    随着 DP计算 参考,如果你想支持您的布局或绘制到S3则计算说

    for example to find the Samsung Galaxy S3 dp to suffix to drawable-sw?dp
    With reference of DP Calculation, If you want to support your layout or drawable to S3 then the calculation says

    PX =设备的宽度= 720
    DPI =设备的密度= 320

    公式给出

        px = dp * (dpi / 160)
    

    交换公式,因为我们有PX的价值

    interchanging formula because we have px's value

        dp = px / (dpi / 160)
    

    现在将值,

         dp= 720 / (320/160);
         dp=360. 
    

    绘制-sw360dp 将做的工作。

    获取你的设备configuaration从 GsmArena 同一开头,你也可以根据设备的Andr​​oid API版本即绘制-HDPI-v11`创建文件夹,以便其有API11,这是华电国际,那么使用这个资源的设备。

    Get you Device configuaration from GsmArena Sameway you can also create folder according to Device's Android API version i.e. drawable-hdpi-v11` so the device which is having API11 and it is Hdpi then it will use this resources.

    其他提示:

    • 使用相对布局,DP,SP和毫米

    • Use relative layouts, dp, sp, and mm

    DP单元 - 归为1的物理像素160 ppi的屏幕即中密度上与设备无关的像素。缩放在运行时。使用的屏幕元素的尺寸

    dp units - device independent pixels normalised to 1 physical pixel on a 160 ppi screen i.e. medium density. Scaled at runtime. Use for screen element dimensions

    SP单元 - 缩放像素,指定为浮点值的基础上,DP单位,但额外的调整以适合用户的字体大小preference设置。缩放在运行时。 使用的字体大小

    sp units - scaled pixels, specified as floating point values, based on dp units but additionally scaled for the user's font-size preference setting. Scaled at runtime. Use for font sizes

    你应该总是使用RelativeLayout的用于布局; AbsoluteLayout是德precated并且不应使用。

    使用适当的图像格式 - PNG与JPEG

    Use appropriate image formats - PNG versus JPEG

    Android的prefersPNG位图图像文件,接受JPEG和鼓励GIF。

    不过,PNG和JPEG不等值。他们有不同的质量权衡和PNG并不总是最好的:

    However, PNG and JPEG are not equivalents. They have different quality trade offs, and PNG is not always best:

    JPEG 可提供高达50%的文件大小减少了PNG,这是显著,如果你的应用程序是图像密集型

    JPEG can offer up to 50% file-size reductions over PNG, which is significant if your app is image-intensive

    一个更高质量的有损JPEG可能看起来优于高度COM pressed无损PNG,对于相同的文件大小

    A higher quality "lossy" JPEG may look better than a highly compressed "lossless" PNG, for the same file size

    标签添加到您的图像和图形调试

    Add labels to your images and graphics for debugging

    使用支架,屏幕元素

    与真实的设备值来配置你的模拟器

    Configure your emulators with real device values

    传统上,桌面系统在72ppi显示(苹果机),或96ppi(Windows和Linux)。与手机相比,台式机显示器始终是低密度。

    Conventionally, desktop systems display at 72ppi (Mac), or 96ppi (Windows, Linux). Compared with mobile, desktop displays are always low density.

    请务必配置的Andr​​oid模拟器来模拟真实的设备价值,并始终将其扩展到模拟设备的密度。

    Always configure your Android emulators to mimic real device values, and always set them to scale to emulate device density.

    在Eclipse中,可以很容易地创建多个仿真器(从Eclipse菜单栏中,选择窗口> AVD管理>新)配置与实际设备的值:

    In Eclipse, it's easy to create multiple emulators (from the Eclipse menu bar, select Window > AVD Manager > New) configured with values for real devices:

    命名模拟器真实的设备它的模拟 指定决议,不​​使用内置的通用尺寸 设置设备的密度相匹配的真实设备(在硬件窗格中设置抽象LCD房产的真实密度,总是一个整数值)

    Name the emulator for the real device it's emulating Specify Resolution, don't use Built-in generic sizes Set the device density to match the real device (in the Hardware pane set Abstracted LCD Property to the real density, always an integer value)

    当您启动设备,始终选择刻度显示实际尺寸和类型的以英寸为单位的实际屏幕尺寸。

    When you launch the device, always select Scale display to real size, and type in the real screen dimension in inches.

    如果您没有设置该设备的密度,模拟器默认为密度低,始终加载LDPI特定资源。分辨率(像素大小)是正确的,但你的密度相关的图像资源,将不显示预期。

    If you don't set the device density, the emulator defaults to low density, and always loads ldpi-specific resources. Resolution (pixel dimensions) will be correct, but your density-dependent image resources will not display as intended.

    当然,没有什么你会较低的密度桌面显示器上再现更高密度的图像质量。

    Of course, nothing you do will reproduce higher density image quality on a lower density desktop display.

    下面是在10月1日结束了7天期间收集的数据,2012年要查看有关Android平台版本的最新统计数据,的去这里

    Here is the Data collected during a 7-day period ending on October 1, 2012. To see the latest statistic about Android platform version, go to here

    根据屏幕大小

    基于屏幕像素密度

    这篇关于应用程序框架,支持多屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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