-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: bug in getSafeAreaRect calculations #1876
Comments
Have you checked the |
@crazyhappygame I just had a look at this, and on creating a new project, and displaying this on an Android device with rounded corners, and the result seems correct: There is no information in your initial post regarding how you set up the resolution policy, or any sample code, so there is nothing to go off in order to reproduce the issue quickly. The above screenshot was taken with a the resolution policy set to |
When using It does go into the rounded corners on the right, which isn't optimal, but, it turns out that there is currently no way to determine if a device has rounded corners on Android. The left side of that screenshot is inset correctly because of the cutout (where the camera is etc.). https://stackoverflow.com/a/50205832/1664652 The suggestion is that you have a list of device names and adjust the sizing based on that, which you can do in your own project as you come across more devices with the issue. Alternatively, set a fixed cut-out size so it doesn't go all the way to the edge of the screen, regardless of what type of screen it is, assuming most screen released these days have rounded corners. This is the method I personally use for getting around this issue. This is not a bug in Axmol. |
I used FIXED_WIDTH. Maybe we can use this: |
This applies to API31 (Android12) or higher, and it's not as straightforward as it may seem. An attempt to utilize this is in PR #1934, so try it out when you can, and let me know if it works for you. I've tested all ResolutionPolicy types on it, and the safe area is correct on all when using the changes in that PR. |
Steps to Reproduce:
auto safeAreaRect = _director->getSafeAreaRect();
Please check screenshots below. Blue rectangle it is safeAreaRect. For Android devices with rounded corners blue is not drawn properly.
Android incorrect: moto G54 (the same issue on other Android devices with rounded corners)
IPhone correct: iPhone Max Pro 15
The text was updated successfully, but these errors were encountered: