最佳做法,以针对Android上多种屏幕分辨率时使用做法、多种、屏幕分辨率、Android

2023-09-05 05:05:02 作者:①訫枳愛①嗰朲

在设计的用户界面,我们需要针对众多Android突变和各种屏幕分辨率。

When designing an UI, we need to target many android mutations and various screen resolutions.

How区分为480 * 800和480 * 854的屏幕分辨率布局的Andr​​oid? how为在Android的各种屏幕布局的支持? How to differentiate layout for 480 * 800 and 480 * 854 screen resolutions in android? how to layout support for various screen in android?

这两个问题上面推荐使用不同的布局code代表不同的屏幕。是不是真的有必要吗?

Both questions above recommend to use different Layout code for different screens. Is it really necessary?

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

建议

提供不同的布局不同的屏幕尺寸

提供不同的位图可绘制不同的屏幕密度

但我仍然认为,我们可以支持多屏幕,而无需创建独立的布局每个屏幕的分辨率。还是我错了?

But I still think, we can support multiple screens without creating standalone layout for each screen resolution. Or am I wrong?

我知道,我做的使用,9补丁可扩展的背景图像(或表单输入,等等) 而我使用DP(密度像素)申报的尺寸相对于屏幕像素密度

I know, and I do use, 9-patch for scalable background images (or form inputs, and so on) and I do use dp (density pixel) to declare sizes relatively to screen density

但什么是下一个最好的做法

推荐答案

我认为这个问题的答案,最近改变了,但我过去的历史的解决方案。

I think the answer to this has changed recently, but I'll go over historical solutions.

$ P $对蜂窝,该解决方案是创建一个动态布局本身足以适应屏幕的尺寸(用9-贴剂,蘸料,即扩展/收缩的布局,等)。这意味着,没有你的意见可能是像素完美,但你可以调整你遇到不同的纵横比。有时候,你会拿出不同的布局进行横向和纵向,但除此之外,定制化是没有必要的。

Pre-Honeycomb, the solution was to create a dynamic layout that could adjust itself to the size of the screen (using 9-patches, dips, layouts that expand/shrink, etc.). This meant that none of your Views could be "pixel perfect", but you could adjust to different aspect ratios that you encounter. Sometimes you would come up with different layouts for landscape and portrait, but beyond that customization wasn't necessary.

通过蜂窝的发布,这一问题得到了很多更加复杂。现在,你已经得到了显着不同的屏幕尺寸,在您的应用程序拉伸不好看的。你就是我的延伸,从7到10平板电脑 - 其中之一就是大与XLARGE? 3.0和3.1是一个尴尬的时期,在那里你必须检测API版本/屏幕尺寸并相应地配置您的应用程序(假设你的应用程序同时支持手机和平板电脑)。

With the release of Honeycomb, the problem got a lot more complex. Now you've got dramatically different screen sizes, where your app stretching doesn't look good at all. You've got tablets that stretch from 7" to 10" - which one is "large" vs. "xlarge"? 3.0 and 3.1 were an awkward period, where you had to detect the API version/screen size and configure your app accordingly (supposing your app supports both phones and tablets).

然而,在3.2及以后一切都变了。现在,最好的做法可以这样描述:觉得像一个网页设计师,而不是一个Android设计师。而是想着手机与平板电脑与横向和纵向布局,想起上,而不是特定的屏幕尺寸的工作布局。

However, everything's changed in 3.2 and beyond. Now, the best practice can be described thus: think like a web designer, not an Android designer. Instead of thinking about phone vs. tablet vs. landscape vs. portrait layouts, think instead of layouts that work on particular screen sizes.

这个思考过程是由这篇博客文章详细介绍< /一>和这些幻灯片的,但我认为这是最好的证明去一些示例网页,看到它的行动。尝试访问此页面(或的此页面,或此页面)和改变浏览器的大小。注意根据宽度如何动态地更改布局 - 这是你想要在Android的东西,以及

This thought process is detailed by this blog post, and these slides, but I think it's best demonstrated by going to some sample web pages and seeing it in action. Try visiting this page (or this page, or this page) and changing the size of your browser. Notice how they dynamically change layout based on the width - this is what you want in Android as well.

所以,现在你就是我的屏幕宽度150dp和400dp的工作布局;另外一个,401dp和800DP的作品;第三,处理800DP和1000dp,等等。这种思维方式不结了你,作为一个开发者,做得太多比以前更多的工作 - 而不是定义手机的布局,平板电脑布局(每一个纵向/横向布局),你只定义了不同宽度的工作,几个布局。

So now you've got a layout that works between screen width 150dp and 400dp; another one that works between 401dp and 800dp; a third that handles 800dp and 1000dp, etc. This way of thinking does not end up with you, as a developer, doing too much more work than before - instead of defining a phone layout, a tablet layout (each with a portrait/landscape layout), you just define a few layouts that work with different widths.

目前,我们正处在一个尴尬的过渡阶段,因为大多数人的不的具有支持这种做法的设备。因此,最佳实践本质上是以上所有。在短短几年内,当每个人的得到ICS和超越,然后我们都可以呼吸了一口气。

Right now we're in an awkward transitional stage as most people don't have devices that support this practice. So "best practice" is essentially all of the above. In a few years, when everyone's got ICS and beyond, then we can all breath a sigh of relief.

(我很抱歉,如果你正在寻找具体的解决办法,这个答案最终被相对理论化,而不是具体的答案,主要是因为我觉得这个问题是pretty的开放式的。如果你有一个具体的问题。你想解决,我可以尝试解决其他地方。)

(I apologize if you were looking for specific solutions; this answer ended up being relatively theoretical rather than having concrete answers, mostly because I felt the question was pretty open-ended. If you've got a specific problem you want to solve, I can try to address that elsewhere.)