不同分辨率支持android [英] Different resolution support android

查看:90
本文介绍了不同分辨率支持android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已编辑的问题:

移动分辨率:
我想设计不同的屏幕dpi,例如以下分辨率.
320x480,
480×800,
540x960,
720x1280(Samsung S3),
1080x1920(S4,Nexus5,Nexus 5x,Moto G4),<25> x 1440(Nexus 6,Nexus 6p,三星edge)

平板电脑分辨率:
480x800(micromax),
600x1024(samsung tab2),
800x1280(nexus 7),
1200x1920(new nexus 7),
2048x1536 (关系9)

Mobile Resolution:
I would like to design different screen dpi like following resolutions.
320x480,
480×800,
540x960,
720x1280 (Samsung S3),
1080x1920 (S4, Nexus5,Nexus 5x, Moto G4),
2560 x 1440 (Nexus 6, Nexus 6p, Samsung edge)

Tablet Resolution:
480x800 (micromax) ,
600x1024 (samsung tab2),
800x1280 (nexus 7),
1200x1920 (new nexus 7),
2048x1536 (nexus 9)

我要使用不同的字体大小,具体取决于设备的显示分辨率.

I want to use different font sizes depending on the device display resolution.

Q1)解决此problembest方法是什么?

Q1) What is the best way to solve this problem?

Q2)做抛出编码或XML的最佳选择是什么?

Q2) What is best option doing throw coding or XML?

Q3)哪个drawable文件夹代表哪种设备分辨率?

Q3) Which drawable folder is represent which device resolution?

Q4)应用启动器图标大小是否适用于不同分辨率?

Q4) Application Launcher icon size for different resolution?

推荐答案

不同分辨率的应用启动器图标大小(以像素为单位)

移动分辨率

  • mipmap-mdpi(48X48)
  • mipmap-hdpi(72X72)
  • mipmap-xhdpi(96X96)
  • mipmap-xxhdpi(144X144)
  • mipmap-xxxhdpi(192X192)

如果您希望使用数位板特定的布局,请使用以下文件夹:

Use following folders if you wish to have tablet-specific layouts:

layout-large-mdpi   (1024x600)
layout-large-tvdpi  (800x1280)
layout-large-xhdpi  (1200x1920)
layout-xlarge-mdpi  (1280x800)
layout-xlarge-xhdpi (2560x1600)

Drawables文件夹:

  1. 移动

  1. Mobile

res/drawable        (default)
res/drawable-ldpi/  (240x320 and nearer resolution)
res/drawable-mdpi/  (320x480 and nearer resolution)
res/drawable-hdpi/  (480x800, 540x960 and nearer resolution)
res/drawable-xhdpi/  (720x1280 - Samsung S3, Micromax Canvas HD etc)
res/drawable-xxhdpi/ (1080x1920 - Samsung S4, HTC one, Nexus 5, etc)
res/drawable-xxxhdpi/ (1440X2560 - Nexus 6,Samsung S6edge).

  • 平板电脑分辨率:

  • Tablet Resolution:

    注意::每次处理textSize时都应尝​​试使用SP,例如textsize=12sp

    NOTE: Always try to use SP whenever you deal with textSize, like textsize=12sp

    1. 使用预定义的textAppearance:

    它将根据设备密度自动设置文本大小.

    It will set text size automatically as per device density.

    <TextView android:textAppearance="?android:attr/textAppearanceSmall"/>
    <TextView android:textAppearance="?android:attr/textAppearanceMedium"/>
    <TextView android:textAppearance="?android:attr/textAppearanceLarge" />
    

    样品用量:

    <TextView
        style="@android:style/TextAppearance.Small"
        android:text="Sample Text - Small" />
    <TextView
        style="@android:style/TextAppearance.Medium"
        android:text="Sample Text  - Medium" />
    <TextView
        style="@android:style/TextAppearance.Large"
        android:text="Sample Text  - Large" />
    

  • 为每个设备使用dimension.xml:

    Google IO Pdf 中,我们看到以下结构:

    From Google IO Pdf, we see structure below:

    1. 移动电话:

    1. Mobile:

    res/values/dimens.xml(default)
    res/values-ldpi/dimens.xml   (240x320 and nearer resolution)
    res/values-mdpi/dimens.xml   (320x480 and nearer resolution)
    res/values-hdpi/dimens.xml   (480x800, 540x960 and nearer resolution)
    res/values-xhdpi/dimens.xml  (720x1280 - Samsung S3, Micromax Canvas HD, etc)
    res/values-xxhdpi/dimens.xml (1080x1920 - Samsung S4, HTC one, etc)
    

    res/values-xxxhdpi/dimens.xml(1440X2560-Nexus 6,三星S6edge).

    res/values-xxxhdpi/dimens.xml (1440X2560 - Nexus 6,Samsung S6edge).

  • 平板电脑:

  • Tablet:

    对于平板电脑,您可以使用更具体的文件夹,例如values-xlargevalues-large.

    For tablet you can use more specific folder like values-xlarge, values-large.

    res/values-large/dimens.xml      (480x800)
    res/values-large-mdpi/dimens.xml (600x1024)
    

    res/values-sw600dp/dimens.xml      (600x1024)
    res/values-sw720dp/dimens.xml      (800x1280)
    res/values-xlarge-xhdpi/dimens.xml (2560x1600 - Nexus 10")
    res/values-large-xhdpi/dimens.xml  (1200x1920 - Nexus 7"(latest))
    

  • 有关更多信息:

    1. 请参阅支持多个屏幕.

    请参阅 Google IO Pdf 的第77页,以获取设计

    See Page# 77 of Google IO Pdf for Design device density. In that, you will find the way to handle dimens.xml for different different devices.

    摘录自支持多个屏幕:

    与密度无关的像素等效于像素上的一个物理像素 160 dpi屏幕,这是系统假定的基线密度 用于中" 密度屏幕.在运行时,系统透明 根据实际情况处理dp单位的任何缩放 使用中的屏幕密度. dp单位到屏幕的转换 像素很简单:px = dp * (dpi / 160).例如,在240 dpi上 屏幕,1 dp等于1.5物理像素.您应该始终使用dp 定义应用程序用户界面时的单位,以确保正确显示 屏幕上具有不同密度的用户界面.

    The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.

    这篇关于不同分辨率支持android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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