What resource qualifier should I use to support 1080p, 720p Android TV? - Android

To determine the different size values โ€‹โ€‹for the 1080p and 720p TV player, I need to decide which qualifier I should use. When I try to use something like values-sw1080p, values-sw720p, this will not work. Values โ€‹โ€‹in dimes.xml do not affect anything. But it works if I use a classifier like -sw540dp, -sw360dp. I really donโ€™t understand why. Any ideas? Thanks.

+6
source share
2 answers

First of all, you are basically right. you can use

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

The reason sw720p/sw1080p does not work is because they do not exist as qualifiers.

This is the official documentation for working with different screen sizes. As you can read, there are two different blocks that you need to consider if you want to calculate your dp folder: the number of pixels (e.g. 720) and the pixel density (i.e., dot-inch block or how many pixels fit into one inch).

The formula is pretty simple:

 px = dp * (dpi / 160) 

whereas in this case we have:

 dp = px * 160 / dpi 

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

Densities table

Suppose we have a 1080p high-density display (@ 320 dpi). We do math

 dp = 1080 * 160 / 320 = 540 

So, we get the appropriate folder to host your resources.


EDIT : This page also states that there is a specific tvdpi qualifier that you can use for your TV-related resources (about 213 dpi ).

+4
source

There are three screen densities that can be considered for Android TV and three corresponding qualifiers. These include:

  • tvdpi - (213dpi) - designed for 720p TVs;
  • xhdpi - (320 dpi) - designed for TVs with a resolution of 1080p (HD);
  • xxxhdpi - (640 dpi) - designed for TVs with a resolution of 4 thousand (Ultra HD).

But according to https://developer.android.com/training/tv/start/layouts.html#density-resources :

Your TV mockup should be set to a screen size of 1920 x 1080 pixels [standard 1080p / HD] and then allow the Android system to reduce the size of the layout elements to 720p if necessary.

This means that if you follow this advice and always develop 1080p specifications, you can use the -television UI Mode Qualifier and do with it.

If you need to deliver different images and layouts for different TV sizes, you can use the screen density qualifiers above.

The โ€œstandardโ€ images and layouts for a TV can be stored in the -xhdpi folder, since xhdpi is the identifier used for 1080p TVs.

If (optionally) high-resolution image versions are required for 4K TVs, they can be represented as โ€œ2xโ€ images and saved in the drawable-xxxhdpi . Likewise, sizes / layouts intended only for targeting 4k TVs can be placed in -xxxhdpi .

(Note that the -tvdpi specifier is specific to 720p and is almost certainly not what you want to use to support modern TVs.)

The documentation is sparse and a bit controversial, but I mainly base it on these sources:

https://developer.android.com/guide/practices/screens_support.html fooobar.com/questions/71581 / ...

+3
source

Source: https://habr.com/ru/post/981094/


All Articles