@@ -34,17 +34,29 @@ public static UIWidgetsViewController getInstance() {
34
34
private UIWidgetsViewMetrics viewMetrics ;
35
35
private boolean keyboardOpen ;
36
36
37
+ private float statusHeight ;
38
+ private float navigationBarHeight ;
39
+
37
40
private void setup () {
38
41
//Log.i("tag", "On Setup 2");
39
42
40
43
keyboardOpen = false ;
41
44
viewMetrics = new UIWidgetsViewMetrics ();
42
-
45
+ setupHeights ();
43
46
updateViewMetrics ();
44
47
45
48
setupViewMetricsChangedListener ();
46
49
}
47
50
51
+ private void setupHeights () {
52
+ final View unityView = ((ViewGroup )UnityPlayer .currentActivity .findViewById (android .R .id .content )).getChildAt (0 );
53
+ Rect rect = new Rect ();
54
+ unityView .getWindowVisibleDisplayFrame (rect );
55
+
56
+ statusHeight = rect .top ;
57
+ navigationBarHeight = unityView .getRootView ().getHeight () - rect .bottom ;
58
+ }
59
+
48
60
public static UIWidgetsViewMetrics getMetrics () {
49
61
UIWidgetsViewController controller = getInstance ();
50
62
return controller .viewMetrics ;
@@ -111,7 +123,7 @@ private boolean hasNavigationBar() {
111
123
} catch (Exception e ) {
112
124
e .printStackTrace ();
113
125
}
114
- // Log.i("UIWidgetsDebug", " hasBar: " + hasBar);
126
+ Log .i ("UIWidgetsDebug" , " hasBar: " + hasBar );
115
127
return hasBar ;
116
128
}
117
129
@@ -120,7 +132,7 @@ public void updateViewMetrics() {
120
132
Rect rect = new Rect ();
121
133
unityView .getWindowVisibleDisplayFrame (rect );
122
134
123
- // Log.i("UIWidgetsDebug", "calculation: " + unityView.getRootView().getHeight() + " " + rect.bottom + " " + rect.top);
135
+ Log .i ("UIWidgetsDebug" , "calculation: " + unityView .getRootView ().getHeight () + " " + rect .bottom + " " + rect .top );
124
136
125
137
rect .bottom = unityView .getRootView ().getHeight () - (rect .bottom - rect .top ) - rect .top ;
126
138
rect .right = unityView .getRootView ().getWidth () - (rect .right - rect .left ) - rect .left ;
@@ -143,9 +155,13 @@ public void updateViewMetrics() {
143
155
viewMetrics .insets_bottom = navigationBarHidden ? calculateBottomKeyboardInset (rect ) : rect .bottom ;
144
156
viewMetrics .insets_left = 0 ;
145
157
146
- //Log.i("UIWidgetsDebug", "checks: " + navigationBarHidden + " " + rect.bottom);
147
- //Log.i("UIWidgetsDebug", " padding: " + viewMetrics.padding_top + " " + viewMetrics.padding_right + " " + viewMetrics.padding_bottom + " " + viewMetrics.padding_left);
148
- //Log.i("UIWidgetsDebug", " insets: " + viewMetrics.insets_top + " " + viewMetrics.insets_right + " " + viewMetrics.insets_bottom + " " + viewMetrics.insets_left);
158
+ //adjust
159
+ viewMetrics .insets_bottom -= navigationBarHeight ;
160
+ viewMetrics .padding_top -= statusHeight ;
161
+
162
+ Log .i ("UIWidgetsDebug" , "checks: " + navigationBarHidden + " " + rect .bottom );
163
+ Log .i ("UIWidgetsDebug" , " padding: " + viewMetrics .padding_top + " " + viewMetrics .padding_right + " " + viewMetrics .padding_bottom + " " + viewMetrics .padding_left );
164
+ Log .i ("UIWidgetsDebug" , " insets: " + viewMetrics .insets_top + " " + viewMetrics .insets_right + " " + viewMetrics .insets_bottom + " " + viewMetrics .insets_left );
149
165
}
150
166
151
167
public void setupViewMetricsChangedListener () {
0 commit comments