Android多屏设计 [英] Android multiple screen design

查看:126
本文介绍了Android多屏设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解有很多关于在Android中设计多屏支持的文档.并且我已经在此处阅读了Android指南,以及许多类似的问题例如

I understand there is plenty of documentation about designing for multiple screen support in Android. and I have read the Android guide here as well as a number of similar questions such as this

但是,对于如何为应用程序实现它,我仍然有些困惑.我打算针对以下设备配置

However I'm still a little confused as to how I should implement it for my application. I plan to target the following device configurations

我是正确的想法,我将需要按以下方式构建项目布局:

Am I correct in thinking I will need to structure the project layouts as follows:

  • 中密度普通屏幕HVGA 320x480(160dpi):

  • Medium density Normal screens HVGA 320x480 (160dpi):

res/layout-mdpi (320 x 480 )
res/layout-land-mdpi (480 x 320 )

  • 高密度普通屏幕WVGA800 480x800(x854)(240 dpi)

  • High density Normal screens WVGA800 480x800 (x854) (240 dpi)

    res/layout-hdpi (480 x 800)
    res/layout-land-hdpi (800 x 480)
    

  • 那中等密度的大屏幕设备呢?

    But what about the Medium density, large screen devices?

    我计划同时使用高密度和中密度可绘制材料集.在此早期阶段,我主要关心的是为每种布局使用合适的背景图像.例如,为了支持 480x800和480x854尺寸,我计划仅使用ImageView作为背景,例如:

    I plan to use sets of both high and medium density drawables too. My primary concern at this early stage is using suitable background images for each layout. For example, to support both the 480x800 and 480x854 sizes, I plan to simply use an ImageView as the background such as:

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/bg"
        android:scaleType="center"/>
    

    "bg"可绘制对象将始终为 480x854 并使用:

    The 'bg' drawable will always be 480x854 and by using:

    android:scaleType="center"
    

    我希望这能解决这两个屏幕尺寸.从而图像保持其原始外观,但以480x800屏幕为中心.我会从图像上损失一些像素,但是只要不缩放图像就可以满足我的需求.

    I'm hoping this will take care of those two screen sizes. Whereby the image keeps its original appearance but is centred on the 480x800 screens. I will lose some pixels off the image but as long as the image isn't scaled then that suits my needs.

    我计划为普通屏幕设置一组320x480的资源.

    I plan to have a set of 320x480 assets for the normal screens.

    我只是希望我能按照正确的程序进行操作,因此,我感谢你们提供的任何信息/提示.预先感谢

    I'm just hoping I'm following the correct procedure here so I appreciate any info/tips from you guys. Thanks in advance

    推荐答案

    根据我的经验,只要您具有用于不同的密度.如文档所述,Android会尝试在不同的屏幕尺寸上正确渲染布局.

    In my experience you don't really need to customize your layout for the small/medium/large/etc screens, as long as you have your drawables for the different densities. Like the documentation says, Android will attempt to render your layout properly on different screen sizes.

    默认情况下,Android会调整应用程序布局的大小以适合当前设备屏幕.在大多数情况下,这可以正常工作.在其他情况下,您的UI可能看起来不那么好,可能需要针对不同的屏幕尺寸进行调整.

    By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes.

    其他情况"仅在您确实想更改大屏幕上的布局时适用.

    The 'other cases' applies only if you really want to change your layout on larger screens.

    使用android:scaleType="center"对我有用,但就像您说的那样,它将在较大的屏幕上的布局周围保留空白,如果它也适合较小的屏幕.如果您有一个完全定制的视图,其中的小部件"应放置在正确的位置,并且您不想以编程方式确定缩放比例并将相同的缩放比例应用于窗口小部件,那么绝对是这样的方法.

    Using android:scaleType="center" works for me, but it will, like you said, leave empty space around your layout on larger screens if it should fit on smaller screens as well. If you have a fully customized view with 'widgets' that should be placed exactly right, and you don't want to be programmatically determining the scaling and applying the same scaling to your widgets, this is definitely the way to go.

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

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