显示设置#

There are two variables that set the content scaling for Lomiri and Ubuntu Touch applications: GRID_UNIT_PX and QTWEBKIT_DPR.

There are also other options available that may be useful for you depending on your device’s form factor. These are mentioned below and explained in depth in the section on display settings.

All of these settings are guessed by Unity 8 if none are set. There are many cases, however, where the guess is wrong (for example, very high resolution phone displays will be identified as desktop computers). To manually set a value for these variables, simply edit the file at etc/ubuntu-touch-session.d/android.conf specifying them. For example, this is the file for the Nexus 7 tablet:

$ cat /etc/ubuntu-touch-session.d/flo.conf
GRID_UNIT_PX=18
QTWEBKIT_DPR=2.0
NATIVE_ORIENTATION=landscape
FORM_FACTOR=tablet

The method for deriving values for these variables is explained below.

Once you have adjusted the android.conf file to the display settings needed for your device, this file should be incorporated into your build. Follow the overlay file method corresponding to your Halium version.

备注

This way of configuration is considered legacy and will be replaced by DeviceInfo in the future. For migration purposes please set both configurations (android.conf as well as DeviceInfo).

Determining the correct display settings#

显示缩放#

GRID_UNIT_PX (Pixels per Grid Unit or Px/GU)用于每个设备。目标是使系统用户界面和应用具有一致的“感官”大小,而不管它们显示在什么设备上。它主要取决于设备屏幕的像素密度和用户到屏幕的距离。后一个值不能自动检测,它是基于启发式的。我们假设平板电脑和笔记本电脑的距离是一样的,它们的距离是手机的1.235倍。

``QTWEBKIT_DPR``设置Oxide网页引擎的显示尺寸,本值的改变将影响浏览器和web应用的尺寸。

选择了一个参考设备,可从中得出所有其他设备的值。参考设备是一个120ppi屏幕的手持电脑。但是,由于这些选项是针对*感知*大小而不是*物理*大小设置的,因此没有确切的公式。 以下是其他设备的一些值,因此你可以为自己的设备得出正确的值:

设备

分辨率

显示大小

PPI

Px/GU

QtWebKit DPR

“正常”屏幕像素密度的笔记本电脑

N/A

N/A

96-150

8

1.0

ASUS Nexus 7

1280x800

7 英寸

216

12

2.0

高密度笔记本

N/A

N/A

150-250

16

1.5

Samsung Galaxy Nexus

1280x720

4.65”

316

18

2.0

LG Nexus 4

1280x768

4.7”

320

18

2.0

Samsung Nexus 10

2560x1600

10.1”

299

20

2.0

Fairphone 2

1080x1920

5 英寸

440

23

2.5

LG Nexus 5

1080x1920

4.95”

445

23

2.5

Experiment with a few values to find one that feels good when compared to the Ubuntu Touch experience on other devices. If you are unsure of which is the best, share some pictures (including some object for scale) along with the device specs with us.

There are two other settings that may be of interest to you:

Form factor#

FORM_FACTOR specifies the device’s form factor. This value is set as the device’s Chassis, which you can find by running hostnamectl. The acceptable values are handset, tablet, laptop and desktop. Apps such as the gallery use this information to change their functionality. For more information on the Chassis, see the freedesktop.org hostnamed specification.

Native orientation#

NATIVE_ORIENTATION sets the display orientation for the device’s built-in screen. This value is used whenever autorotation isn’t working correctly or when an app wishes to be locked to the device’s native orientation. Acceptable values are landscape, which is normally used for tablets, laptops, and desktops; and portrait, which is usually used for phone handsets.