8

I am writing an Android application that needs to calculate the height of screen to display content correctly. But the height I got in Mi devices (Mi 9 SE) wasn't correct when switching to full screen gesture mode. How can I get the real height of the screen, or check if user turned on full screen gesture mode in Mi devices?

I have tried these suggestions.

  1. How to detect full screen gesture mode in android Q
  2. Android: detect navigation bar visibility
  3. Check for navigation bar
Minh Dao
  • 827
  • 8
  • 21

2 Answers2

0

After searching and experimenting, I have found the only solution: How to detect full screen gesture mode in android Q.

Instead of using ViewCompat.setOnApplyWindowInsetsListener() function, I just have to create a WindowInsets instance for the current context, then check the getSystemGestureInsets() for each edges. This is how I implemented to make a React Native's native module.

If you need a listener to detect every changes, the solution above has done well on Android app. If you want this listener for React Native, you might want to find another approach, since I haven't made it work.

Minh Dao
  • 827
  • 8
  • 21
0

A very simpler answer: Don't use DisplayMetrics. Just make any view take full width and height of the screen (MATCH_PARENT) then get it's dimensions, it well give accurate numbers.

Mo Dev
  • 475
  • 6
  • 17