简体   繁体   中英

Android tv layout dimension

Consider this layout in res/layout:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/text_view"
          android:layout_width="160dp"
          android:layout_height="160dp"
          android:background="@color/lb_tv_white"
          tools:context=".MainActivity"
          tools:deviceIds="tv"/>

It is a 160dp * 160dp square so it should appear 1inch * 1inch on all devices according to my understanding. However when I run it on tv it appears much larger than I expected:

on a fire tv stick connected to a 15.6 inch real tv: 在此处输入图片说明

on a 55inch tv emulator: 在此处输入图片说明

They both appear much larger than 1inch * 1inch. Does dp value has different meaning for tv?

On a pixel xl 2: 在此处输入图片说明 As you can see on the pixel xl 2 it is not a square at all.

I believe TVs use dps more like a "standard resolution" where they all have roughly the same so you can plan how things will look instead of physical size, but I haven't been able to find any reference on the official docs.

From the official documentation ( https://developer.android.com/training/tv/start/layouts ):

"A TV screen is typically viewed from about 10 feet away, and while it is much larger than most other Android device displays"

So it may as well be that dips have been adjusted for this distance and are perceived as "the same size" as the ones on a phone held close to your face.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM