I have Android Tv Box and react-native app with a player control on the main screen, and now I need to set player size exactly to 256x128 pixels for showing video on a LED panel.
Currently I use react-native styles to set size of the player component in pixels:
const getStyleForVideoControl = (x, y, width, height) => {
const devicePixelRatio = PixelRatio.get();
function pixelsToDp(pixels) {
return pixels / devicePixelRatio;
}
return {
position: 'absolute',
left: pixelsToDp(x),
top: pixelsToDp(y),
width: pixelsToDp(width),
height: pixelsToDp(height)
};
}
This code works well with different DPIs, but it doesn't work properly when I override device resolution.
For example, I get actual size of the player component 342x171 instead of 256x128 pixels when I override output display resolution 800x1280 -> 1080x1920:
adb shell wm size
Physical size: 800x1280
Override size: 1080x1920
Is it possible to handle overridden screen resolutions in my code to set the player component size properly?