|
9 | 9 | import android.view.Display;
|
10 | 10 | import android.view.View;
|
11 | 11 | import android.view.ViewTreeObserver;
|
| 12 | +import android.view.WindowInsets; |
12 | 13 | import android.view.inputmethod.InputMethodManager;
|
13 | 14 |
|
14 | 15 | import com.getcapacitor.JSObject;
|
@@ -54,18 +55,20 @@ public void onGlobalLayout() {
|
54 | 55 | // cache properties for later use
|
55 | 56 | int rootViewHeight = rootView.getRootView().getHeight();
|
56 | 57 | int resultBottom = r.bottom;
|
57 |
| - |
58 |
| - // calculate screen height differently for android versions >= 21: Lollipop 5.x, Marshmallow 6.x |
59 |
| - //http://stackoverflow.com/a/29257533/3642890 beware of nexus 5 |
60 | 58 | int screenHeight;
|
61 | 59 |
|
62 |
| - if (Build.VERSION.SDK_INT >= 21) { |
| 60 | + if (Build.VERSION.SDK_INT >= 23) { |
| 61 | + WindowInsets windowInsets = rootView.getRootWindowInsets(); |
| 62 | + int stableInsetBottom = windowInsets.getStableInsetBottom(); |
| 63 | + screenHeight = rootViewHeight; |
| 64 | + resultBottom = resultBottom + stableInsetBottom; |
| 65 | + } else { |
| 66 | + // calculate screen height differently for android versions <23: Lollipop 5.x, Marshmallow 6.x |
| 67 | + //http://stackoverflow.com/a/29257533/3642890 beware of nexus 5 |
63 | 68 | Display display = getActivity().getWindowManager().getDefaultDisplay();
|
64 | 69 | Point size = new Point();
|
65 | 70 | display.getSize(size);
|
66 | 71 | screenHeight = size.y;
|
67 |
| - } else { |
68 |
| - screenHeight = rootViewHeight; |
69 | 72 | }
|
70 | 73 |
|
71 | 74 | int heightDiff = screenHeight - resultBottom;
|
|
0 commit comments