浏览代码

Android navigation bar height bug fix

/main
xingwei.zhu 6 年前
当前提交
6dac96ef
共有 1 个文件被更改,包括 23 次插入1 次删除
  1. 24
      Runtime/Plugins/platform/android/view/UIWidgetsViewController.java

24
Runtime/Plugins/platform/android/view/UIWidgetsViewController.java


import android.view.ViewTreeObserver;
import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.view.Surface;
import java.util.Arrays;
import android.view.WindowManager;

}
}
private int getNavigationBarHeight() {
Resources resources = UnityPlayer.currentActivity.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0)
{
return hasNavigationBar() ? resources.getDimensionPixelSize(resourceId) : 0;
}
return 0;
}
private boolean hasNavigationBar() {
Resources resources = UnityPlayer.currentActivity.getResources();
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
return id > 0 && resources.getBoolean(id);
}
public void updateViewMetrics() {
final View unityView = ((ViewGroup)UnityPlayer.currentActivity.findViewById(android.R.id.content)).getChildAt(0);
Rect rect = new Rect();

ZeroSides zeroSides = ZeroSides.NONE;
if (navigationBarHidden) {
zeroSides = calculateShouldZeroSides(unityView);
} else {
rect.bottom -= getNavigationBarHeight();
rect.bottom = rect.bottom > 0 ? rect.bottom : 0;
viewMetrics.padding_left = zeroSides == ZeroSides.LEFT || zeroSides == ZeroSides.BOTH ? 0 : rect.left;
viewMetrics.padding_left = zeroSides == ZeroSides.LEFT || zeroSides == ZeroSides.BOTH ? 0 : rect.left;
viewMetrics.insets_top = 0;
viewMetrics.insets_right = 0;

正在加载...
取消
保存