我应该使用哪个资源限定符来支持1080p

我应该使用哪个资源限定符来支持1080p

本文介绍了我应该使用哪个资源限定符来支持1080p,720p android TV? - 安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了为1080p和720p android TV定义不同的尺寸值,我需要确定应该使用哪个限定符.当我尝试使用values-sw1080p,values-sw720p之类的东西时,它不起作用. dimes.xml中的值不会有任何影响.但是,如果我使用的是-sw540dp,-sw360dp这样的限定词,它就可以工作.我真的不明白为什么会这样.任何的想法?谢谢.

In order to define different dimension values for 1080p and 720p android TV, I need to decide which qualifier I should use. When I'm trying to use something like values-sw1080p,values-sw720p, it doesn't work. The values in dimes.xml doesn't affect anything. But it works if I'm using qualifier like -sw540dp,-sw360dp. I don't really understand why like that. Any idea? Thanks.

推荐答案

首先,您基本上是正确的.您可以使用

First of all, you are substantially correct. You can use

sw360dp/ : 720p screens
sw540dp/ : 1080p screens

sw720p/sw1080p不起作用的原因是因为它们不作为限定词存在.

The reason why sw720p/sw1080p don't work is because they don't exist as qualifiers.

这是有关使用不同屏幕尺寸的官方文档.如您所见,如果要计算dp文件夹,可以考虑两种不同的单位:像素数(例如720)和像素密度(即每英寸点数单位),或者一英寸可以容纳多少像素).

This is the official documentation about working with different screen sizes. As you can read, there are two different units to take into account if you want to calculate your dp folder: the pixel count (e.g., 720) and the pixel density (that is, the dot-per-inch unit, or how many pixels fit into a single inch).

公式很简单:

px = dp * (dpi / 160)

在这种情况下,我们有:

while in this case we have:

dp = px * 160 / dpi

当然,电视可以具有不同的密度:此表为您提供了更多有关它的信息(来源:官方文档).

Of course, a TV can have different densities: this table tells you more about it (source: official documentation).

让我们假设我们有一个1080p显示屏,具有超高密度(@ 320 dpi).我们做数学

Let's assume we have a 1080p display with an extra high density (@320 dpi). We do the math

dp = 1080 * 160 / 320 = 540

因此,我们获得了相应的文件夹来放入您的资源.

So we get the appropriate folder to put your resources in.

编辑:在同一页面上,指出存在一个特定的tvdpi限定词,您可以将其用于与电视相关的资源(在213 dpi左右).

EDIT: on that same page, it is stated that there is a specific tvdpi qualifier that you can use for your TV-related resources (around 213 dpi).

这篇关于我应该使用哪个资源限定符来支持1080p,720p android TV? - 安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 09:17