How can I set exact size in pixels for a component in react-native app output when output screen resolution has been overridden on device?

435 views
Skip to first unread message

Naked Man

unread,
Oct 21, 2019, 12:50:41 PM10/21/19
to android-platform
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?

Dr. Dhanyu Eshaka

unread,
Oct 21, 2019, 6:26:07 PM10/21/19
to android-...@googlegroups.com
I have related question on this. Can we write to frameBuffer using Native app? 
If so we can  change the resolution. Not sure we could write an app to do so.

- Dhanyu

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-platform/b77a0957-97d8-4527-bb6f-4fdb7048b574%40googlegroups.com.


--
~Life is beautiful~

Glenn Kasten

unread,
Oct 21, 2019, 6:29:57 PM10/21/19
to android-platform
Sorry this thread is actually off-topic for android-platform but accidentally slipped through moderation;
please use android-ndk instead for any follow-ups or new topics about native C/C++ app development.
Thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.


--
~Life is beautiful~
Reply all
Reply to author
Forward
0 new messages