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

问题描述

我知道有大量的材料有关我的问题。但我仍然感到困惑如何设计Android应用程序,支持屏幕尺寸的差别。

I know there are plenty of materials about my question. But I'm still confused how to design android app to support difference sizes of screen.

大多数时候,我设计网页,我用百分比来支持屏幕大小不同。但你也知道,在Android中,为了做到这一点,我有使用Java code(读宽度和高度,调整所有根据屏幕大小查看),使实时的用户界面,因为使用XML,你可以'做T这一点。但是,这似乎是不对的。

Mostly when I design web, I use percent to support different size of screens. But as you know, in android, in order to do that, I have to make UI in realtime using Java code(read width and height and resize all the Views depending on screen size), because with XML, you can't do this. But this seems not right.

我有图像文件(PNG,JPG),并且我安排这些文件的ImageView和scaleType为fitXY,我设置宽度DP。我知道,DP单位将使这个元素一直同实际规模,为此人们使用它的小部件。所以我把这个形象xxxhdpi屏幕,当我在xhdpi屏幕上看到,形象是如此巨大,图像切割。

I have image files(PNG, JPG), and I arrange these files as ImageView and scaleType as "fitXY" and I set width as DP. I know that "dp" unit will make this element consistently same real size and for this reason people use it for widgets. So I put this image in xxxhdpi screen and when I see in xhdpi screen, image is so huge that the image is cut.

我要的很简单。我想安排视图元素%,至宽,这样的布局是在不同的屏幕上非常相似(不同身高的比例将滚动也许可以解决?)。但我不知道该怎么... ????不仅%的..我只是想知道生成图像文件,并安排不同的屏幕小部件的正常流程...

What I want is very simple. I want to arrange View elements as percent to width so that layout is very similar in different screens(different height ratio will be resolved with scroll maybe?). But I don't know how to...???? Not only percent.. I just want to know normal process of generating image files and arranging widgets for different screens...

我应该为不同的屏幕许多图像文件,并把这些在res /绘-XXXXX?如果我这样做,是否android系统自动使用不同的文件不同的屏幕?或者,我应该让许多布局为每个不同的屏幕上所有的时间(这似乎愚蠢的。)?

Should I make many image files for different screen and put these in res/drawable-xxxxx ? If I do this, does android system use different files for different screen automatically? Or, Should I make many layouts for each different screen all the time(this seems stupid..)?

任何人都可以指导我吗?......我一直在寻找这个答案1周以上。请...

Could anyone guide me please?... I have been looking for this answer more than 1 week. Please...

推荐答案

您可以创建不同的布局文件夹和创建标准的屏幕尺寸布局。有一组六广义密度:

You can create different layout folders and create layouts for standard screen sizes. There is a set of six generalized densities:

ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi

您可以为这些创建图像和布局,并使用accordingly.Mention,在你表现也:

You can create images and layouts for these and use accordingly.Mention that in you manifest also:

<compatible-screens>
    <screen
        android:screenDensity="ldpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="xlarge" />
</compatible-screens>

支持多种屏幕,获取更多详情。

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

09-02 21:39