I am looking for a way to determine whether Android device has screen with rounded corners and ideally also the radius.
My usecase is a game that consist of a single fullscreen OpenGL view. It renders some UI elements close to the edges and borders to give as much area as possible to the game itself. But when the screen has rounded corners, they would be partially hidden, so they need to be positioned differently.
Rounded corners are more effective for maps and diagrams because they allow our eyes to easily follow lines “as it suits better to the natural movement of the head and eyes respectively” [5]. Sharp corners throw your eyes off the path of the line so you end up experiencing abrupt pauses when the line changes direction.
Android S
Developer Preview adds a RoundedCorner
API, via WindowInsets.getRoundedCorner(int position)
. It provides the center point and radius of each rounded corner.
Ref: https://developer.android.com/about/versions/12/features#rounded_corner_apis
Update as of 6th June 2019
Android officially supports display cutouts on devices running Android 9 (API level 28) and higher.
Reference: https://developer.android.com/guide/topics/display-cutout/
Currently (7th May 2018) you can only check if the physical screen is rounded or not (for Android Wear) using [isRounded()][1]
method but can not check if screen corners are rounded.
I think there are only a few devices with rounded corners out there. So it's better to just check the name of device and adjust your layout accordingly.
There is one popular Android library to get the market name of an Android device. Check here for more information: https://github.com/jaredrummler/AndroidDeviceNames/
Usage:
String deviceName = DeviceName.getDeviceName();
Hope this workaround will help you temporarily.
Maybe all devices in the future will release with round corner screens (just an assumption).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With