简体   繁体   English

关于了解支持不同屏幕尺寸的信息

[英]regarding understanding supporting different screen sizes

i referred to a website to know how to create different layout folders to support different screen size. 我提到了一个网站,以了解如何创建不同的布局文件夹以支持不同的屏幕尺寸。 http://wptrafficanalyzer.in/blog/different-layouts-for-different-screen-sizes-in-android/ http://wptrafficanalyzer.in/blog/different-layouts-for-different-screen-sizes-in-android/

in the aforementioned link states the following : 在上述链接中指出以下内容:

res/layout-sw320dp : Devices with a smallest screen width which is greater than 320dp will make use the layouts defined in this folder

res/layout-sw480dp: Devices with a smallest screen width which is greater than 480dp will make use the layouts defined in this folder

my question is, what if there is a devie with screen width of 500dp for exampl, then which folder will be used 'res/layout-sw320dp' or 'res/layout-sw480dp'? 我的问题是,如果有一个屏幕宽度为500dp的devie用于示例,那将使用“ res / layout-sw320dp”或“ res / layout-sw480dp”哪个文件夹?

In the official documentation , under Provide different layouts for different screen sizes , you can read: 官方文档的“ 为不同的屏幕尺寸提供不同的布局”下,您可以阅读:

By default, Android resizes your application layout to fit the current device screen. 默认情况下,Android会调整应用程序布局的大小以适合当前设备屏幕。 In most cases, this works fine. 在大多数情况下,这可以正常工作。 In other cases, your UI might not look as good and might need adjustments for different screen sizes. 在其他情况下,您的UI可能看起来不那么好,可能需要针对不同的屏幕尺寸进行调整。 For example, on a larger screen, you might want to adjust the position and size of some elements to take advantage of the additional screen space, or on a smaller screen, you might need to adjust sizes so that everything can fit on the screen. 例如,在较大的屏幕上,您可能需要调整某些元素的位置和大小以利用额外的屏幕空间,或者在较小的屏幕上,可能需要调整大小以使所有内容都适合屏幕。

The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. 可用于提供特定于大小的资源的配置限定符为small,normal,large和xlarge。 For example, layouts for an extra-large screen should go in layout-xlarge/. 例如,超大屏幕的布局应放在layout-xlarge /中。

Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the swdp configuration qualifier to define the smallest available width required by your layout resources. 从Android 3.2(API级别13)开始,不建议使用上述大小组,而应使用swdp配置限定符定义布局资源所需的最小可用宽度。 For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/. 例如,如果您的多窗格平板电脑布局需要至少600dp的屏幕宽度,则应将其放置在layout-sw600dp /中。

Emphasis mine. 强调我的。

and further down, under Using new size qualifiers : 在“ 使用新的大小限定词”下

For example, if your layout requires that its smallest dimension of screen area be at least 600 dp at all times, then you can use this qualifier to create the layout resources, res/layout-sw600dp/. 例如,如果您的布局始终要求其最小的屏幕区域尺寸至少为600 dp,则可以使用此限定符来创建布局资源res / layout-sw600dp /。 The system will use these resources only when the smallest dimension of available screen is at least 600dp , regardless of whether the 600dp side is the user-perceived height or width. 仅当可用屏幕的最小尺寸至少为600dp时系统才会使用这些资源 ,而不管600dp的边是用户感知的高度还是宽度。

Emphasis mine. 强调我的。

What this means that if you have a sw320dp and a sw480dp folder, a device with a screen width of 500dp will use the sw480dp folder. 这意味着如果您有一个sw320dp和一个sw480dp文件夹,则屏幕宽度为500dp的设备将使用sw480dp文件夹。

A device with a screen width of 479dp will use the sw320dp folder. 屏幕宽度为479dp的设备将使用sw320dp文件夹。

Why don't you read the official documentation ? 您为什么不阅读官方文档

There, in the examples, you can see: 在示例中,您可以在其中看到:

For other cases in which you want to further customize your UI to differentiate between sizes such as 7” and 10” tablets, you can define additional smallest width layouts: 对于要进一步自定义UI以区分尺寸(例如7英寸和10英寸平板电脑)的其他情况,可以定义其他最小宽度布局:

res/layout/main_activity.xml # For handsets (smaller than 600dp available width) res / layout / main_activity.xml#对于手机(可用宽度小于600dp)

res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger) res / layout-sw600dp / main_activity.xml#适用于7英寸平板电脑(宽600dp及更大)

res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger) res / layout-sw720dp / main_activity.xml#适用于10英寸平板电脑(宽720dp以上)

From this you can clearly see that a device with more than 720dp will not use the 600dp files. 从中可以清楚地看到,具有720dp以上的设备将不会使用600dp文件。

So in your example the answer would be the 'res/layout-sw480dp' folder. 因此,在您的示例中,答案将是“ res / layout-sw480dp”文件夹。

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

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