On a 1080p emulator and Smart TV (nVidia Shield) I only get a 960x540 WebView. Is it possible to use the whole resolution available instead?
-
@jaydroider found the mistery. The devicePixelRatio is 2! – Nuthinking Mar 12 '16 at 22:13
-
Have you got solved your issue ? – Jay Rathod Mar 13 '16 at 09:21
-
yes. Being the pixel density double, 960x540 equals to full HD. – Nuthinking Mar 14 '16 at 20:16
-
Did you fix it? How? – atok Dec 05 '16 at 11:16
-
1Any fixes for this? I have an app in 1080p, with fixed UI I do not want to change my UI to fit 960x540. – ToM Sep 03 '19 at 20:27
-
@ToM See answer below, to get access to the pixels available multiply resolution for devicePixelRatio – Nuthinking Sep 04 '19 at 09:36
-
@Nuthinking yes I know how to check devicePixelRatio, however I cannot change it. My use case is that I have a UI in 1080p (which is fixed) and I don't want to downscale it manually to 960x540. Is there a way to change the webview to use full 1080p? – ToM Sep 04 '19 at 09:57
-
@ToM of course you can't change devicePixelRatio, you should change your assets/elements accordingly. In my case, for instance, I made the canvas width equals to the width returned by the browser times devicePixelRatio. Then I fixed its width to the original value via CSS. – Nuthinking Sep 05 '19 at 10:17
-
1@Nuthinking your solution works perfectly with canvas, that is easily scaled. My problem was different, but I fund a bit hackish solution :) – ToM Sep 10 '19 at 08:49
5 Answers
An HDTV using Android TV is considered as 960x540px display with 2x pixel ratio. Not sure how a 4k TV is recognized, but to use all the pixels, check window.devicePixelRatio .

- 1,211
- 2
- 13
- 32
Im looking for an answer to the same question, but i can confirm the following.
1080p TV Testing
each device configured in setting to only use 1080p 60Hz
Amazon Firestick gets 960 x 540 px in all browsers tested.
Shield TV gets 960 x 540 px in all browsers tested.
new Amazon Fire TV Cube gets 960 x 540 px in all browsers tested.
4K TV Testing
Amazon Firestick (not 4K compatible) gets 960 x 540 px in all browsers tested.
Shield TV (with output setting at 4K 60Hz) gets 960 x 540 px in all browsers tested.
new Amazon Fire TV Cube (with output setting 4K 60Hz) gets 960 x 540 px in all browsers tested.
whats more bizarre is that both 1080p and 4K test the reported pixelratio was 2. I at least expected to see a pixel ratio of 4 on 960x540 on 4K
I use TVs connected to PC to display large tables of status data. when fully utilized a 70" 4K TV displays hundreds of different bits of info, its a beautiful thing.
then you get an Nvidia Shield because its "4K" and discover the browser renders at 960 x 540, and the page that looks fantastic in 4K looks like blocky illegible crap.

- 41
- 3
-
Are you basically saying that browsers in Android TV can't render at 4k? Yeah, it would make sense for the pixel ratio to be set to 4. – Nuthinking Jul 24 '18 at 14:50
-
Any fixes for this? I have an app in 1080p, with fixed UI and I do not want to change my UI to fit 960x540. Is there a way to allow 720p or 1080p in Android TV WebView? – ToM Sep 03 '19 at 21:02
This is what I did in Android TV 28 My app original resolution is 1080p
JS Code:
document.body.style.zoom = 1/window.devicePixelRatio

- 384
- 2
- 15
-
2if the whole UI was designed for 1080p, I guess this could be a quick fix. Still a bit hackish though. – Nuthinking Sep 05 '19 at 10:20
You can use WebView#setInitialScale to scale the website according to your needs. To get wanted scale you can use the code:
Point metrics = new Point();
((WindowManager) context.getSystemService(WIDNOW_SERVICE)).getDisplay(metrics);
int scale = (int) (((double) metrics.x) / 3840/*SCREEN_WIDTH*/ * 100);
You should not set additional settings like setUseWideViewPort, because it can overwrite/ignore the scale setting.

- 5,307
- 3
- 23
- 19
After all, someone managed to work with a resolution other than 960 x 540? It's pretty weird having a 60 inch tv with such a small resolution.

- 176
- 1
- 3
- 12
-
devicePixelRatio makes all the difference. It's a multiplier. iPhones, for instance, multiply times 3. My guess is that your devicePixelRatio is 4. Meaning that if you want to show a drawn canvas at full resolution, it has to be 3840x2160 and then scaled to 25% down via CSS. – Nuthinking Jun 02 '23 at 07:44