Android UI设计:支持多个屏幕

时间:2022-05-19 20:07:35

I have read this tutorial SUPPORTING MULTIPLE SCREENS several times and many * questions regarding Design Android UIs to fit well with all android screen sizes.

我已阅读本教程多次支持多个屏幕和许多有关Design Android UI的*问题,以适应所有Android屏幕尺寸。

But still struggling with providing the best and the same user experience for all screen sizes equally.

但仍然在努力为所有屏幕尺寸提供最佳和相同的用户体验。

When I am designing the Interfaces always keeping the following diagram in mind.Android UI设计:支持多个屏幕

当我设计接口时,始终牢记以下图表。

For the moment in my app it uses following folder structure under the res folder.

在我的应用程序中,它使用res文件夹下的以下文件夹结构。

Android UI设计:支持多个屏幕

Also I have used dp and sp units in the xml layout files when defining the sizes.

此外,我在定义大小时在xml布局文件中使用了dp和sp单位。

Small screen sizes

小屏幕尺寸

When it comes to small screen sizes it perfectly refer to the UIs defined under layout-small and display without any issue.

当谈到小屏幕尺寸时,它完美地指代在布局小和显示下定义的UI而没有任何问题。

Normal screen sizes

正常的屏幕尺寸

When I design layouts for normal screen sizes(layout folder), I used 3.5 inches android device and 3.7 inches emulator to test how UI looks like in normal screen size.

当我设计正常屏幕尺寸(布局文件夹)的布局时,我使用3.5英寸的Android设备和3.7英寸的模拟器来测试UI在正常屏幕尺寸下的样子。

So my layouts look excellent in this size but Samsung Gallaxy S3 (4.8 inches) and S4 (5.0 inches) having slightly bigger screens and they still refer to the normal screen sized layouts. Therefore in Those bigger screens have a considerable space left from the bottom not using and UI doesn't look nice.

所以我的布局在这个尺寸上看起来很棒,但是三星Gallaxy S3(4.8英寸)和S4(5.0英寸)的屏幕略大,它们仍然指的是普通屏幕尺寸的布局。因此在那些较大的屏幕中有一个相当大的空间从底部不使用,UI看起来不太好看。

Also In the manifest file, I have defined the following,

另外在清单文件中,我定义了以下内容,

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="17" />

<supports-screens 
    android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true" />

I have no issue with the image density(drawable-hdpi/drawable-xhdpi/drawable-mdpi/drawable-ldpi)

我对图像密度没有任何问题(drawable-hdpi / drawable-xhdpi / drawable-mdpi / drawable-ldpi)

(1). Wonder what I am missing or doing wrong to result like this specially in Bigger screens (4.8 inches) to refer normal layouts.

(1)。不知道我错过了什么或做错了这样的结果,特别是在Bigger屏幕(4.8英寸)中,以引用正常的布局。

(2). Also If someone can explain best practices and the standard way of defining folder structure under the Res folder to fit well with all the screen sizes in android, would be grateful as this is so confusing. Thanks.

(2)。另外如果有人可以解释最佳实践和Res文件夹下定义文件夹结构的标准方法,以适应android中的所有屏幕尺寸,将不胜感激,因为这是如此令人困惑。谢谢。

6 个解决方案

#1


15  

Instead of using the dp size unit you can use the sdp size unit that is relative to the screen size.

您可以使用相对于屏幕大小的sdp大小单位,而不是使用dp大小单位。

Using the sdp size unit you will have the same user experience on all screen sizes with only one layout xml.

使用sdp size单元,您将在所有屏幕尺寸上拥有相同的用户体验,只有一个布局xml。

Use it carefully! for example, in most cases you still need to design a different layout for tablets.

小心使用!例如,在大多数情况下,您仍需要为平板电脑设计不同的布局。

For text view sizes please refer to the ssp size unit (based on the sp size unit)

对于文本视图大小,请参阅ssp大小单位(基于sp大小单位)

#2


3  

You can use the following resource folders to create layouts for devices with larger screens :

您可以使用以下资源文件夹为具有较大屏幕的设备创建布局:

7 inch tablets
res\layout-sw600dp

7英寸平板电脑res \ layout-sw600dp

10 inch tablets
res\layout-sw720dp

10英寸平板电脑res \ layout-sw720dp

#3


1  

If it is very important to specify to that extreme, there is a handy tool for folder naming, and that is chaining. Ex. layout-w480dp-normal and that would be screen sizes at least 480dp in width, and fall under the normal category. Note: I didn't get the need to develop for such detailed requirements, but according to the linked source, it should work just fine.

如果指定到那个极端是非常重要的,那么有一个方便的文件夹命名工具,那就是链接。防爆。 layout-w480dp-normal,屏幕尺寸至少为480dp,属于普通类别。注意:我没有需要开发这样的详细要求,但根据链接的来源,它应该工作得很好。

Source

资源

Make sure to follow these rules

请务必遵守这些规则

#4


1  

For Multiple screen support:

对于多屏幕支持:

  1. Mobile : Create different values folder which is mention below:
  2. 移动:创建不同的值文件夹,如下所示:

values                     (For mdpi devices)
values-hdpi                (For hdpi devices)
values-xhdpi               (For xhdpi devices)
values-xxhdpi              (For xxhdpi devices)

  1. Tablets: Create different layout folder which is mention below:
  2. 平板电脑:创建不同的布局文件夹,如下所示:

layout-sw600dp             (For 7″ to 9″ Screen)
layout-sw720dp             (For 10″ to above screen)

For image resources: Create 4 drawable folders:

对于图像资源:创建4个可绘制文件夹:

drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi

#5


0  

Create different layouts for different screen.

为不同的屏幕创建不同的布局。

res/layout-large/

RES /布局大/

res/layout-sw600dp/

RES /布局sw600dp /

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

Find android UI design examples and tutorials: http://www.viralandroid.com/2015/11/android-user-interface-ui-design-tutorial.html

查找android UI设计示例和教程:http://www.viralandroid.com/2015/11/android-user-interface-ui-design-tutorial.html

#6


0  

Generalized densities.

广义密度。

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

Just Define folder for different image like:

只需为不同的图像定义文件夹,如:

drawable-large-xhdpi: copy (drawable-xxhdpi images)
drawable-xlarge-xhdpi: copy (drawable-xxxhdpi images)
drawable-xxhdpi: 1080x1920 slicing
drawable-xxxhdpi : 1440x25601 slicing

Add support multiple screen size support in manifest.

在清单中添加支持多屏幕尺寸支持。

 <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

Android UI设计:支持多个屏幕

#1


15  

Instead of using the dp size unit you can use the sdp size unit that is relative to the screen size.

您可以使用相对于屏幕大小的sdp大小单位,而不是使用dp大小单位。

Using the sdp size unit you will have the same user experience on all screen sizes with only one layout xml.

使用sdp size单元,您将在所有屏幕尺寸上拥有相同的用户体验,只有一个布局xml。

Use it carefully! for example, in most cases you still need to design a different layout for tablets.

小心使用!例如,在大多数情况下,您仍需要为平板电脑设计不同的布局。

For text view sizes please refer to the ssp size unit (based on the sp size unit)

对于文本视图大小,请参阅ssp大小单位(基于sp大小单位)

#2


3  

You can use the following resource folders to create layouts for devices with larger screens :

您可以使用以下资源文件夹为具有较大屏幕的设备创建布局:

7 inch tablets
res\layout-sw600dp

7英寸平板电脑res \ layout-sw600dp

10 inch tablets
res\layout-sw720dp

10英寸平板电脑res \ layout-sw720dp

#3


1  

If it is very important to specify to that extreme, there is a handy tool for folder naming, and that is chaining. Ex. layout-w480dp-normal and that would be screen sizes at least 480dp in width, and fall under the normal category. Note: I didn't get the need to develop for such detailed requirements, but according to the linked source, it should work just fine.

如果指定到那个极端是非常重要的,那么有一个方便的文件夹命名工具,那就是链接。防爆。 layout-w480dp-normal,屏幕尺寸至少为480dp,属于普通类别。注意:我没有需要开发这样的详细要求,但根据链接的来源,它应该工作得很好。

Source

资源

Make sure to follow these rules

请务必遵守这些规则

#4


1  

For Multiple screen support:

对于多屏幕支持:

  1. Mobile : Create different values folder which is mention below:
  2. 移动:创建不同的值文件夹,如下所示:

values                     (For mdpi devices)
values-hdpi                (For hdpi devices)
values-xhdpi               (For xhdpi devices)
values-xxhdpi              (For xxhdpi devices)

  1. Tablets: Create different layout folder which is mention below:
  2. 平板电脑:创建不同的布局文件夹,如下所示:

layout-sw600dp             (For 7″ to 9″ Screen)
layout-sw720dp             (For 10″ to above screen)

For image resources: Create 4 drawable folders:

对于图像资源:创建4个可绘制文件夹:

drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi

#5


0  

Create different layouts for different screen.

为不同的屏幕创建不同的布局。

res/layout-large/

RES /布局大/

res/layout-sw600dp/

RES /布局sw600dp /

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

Find android UI design examples and tutorials: http://www.viralandroid.com/2015/11/android-user-interface-ui-design-tutorial.html

查找android UI设计示例和教程:http://www.viralandroid.com/2015/11/android-user-interface-ui-design-tutorial.html

#6


0  

Generalized densities.

广义密度。

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

Just Define folder for different image like:

只需为不同的图像定义文件夹,如:

drawable-large-xhdpi: copy (drawable-xxhdpi images)
drawable-xlarge-xhdpi: copy (drawable-xxxhdpi images)
drawable-xxhdpi: 1080x1920 slicing
drawable-xxxhdpi : 1440x25601 slicing

Add support multiple screen size support in manifest.

在清单中添加支持多屏幕尺寸支持。

 <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

Android UI设计:支持多个屏幕