diff --git a/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java b/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java index 388b9fdb27f..c992433cbaa 100644 --- a/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java +++ b/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java @@ -208,6 +208,18 @@ private void removeListeners() { this.removeTextChangedListener(mTextWatcher); } + private boolean isSystemAdjustUIWhenPopKeyboard(int bottom) { + int bottomOffset = 0; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + bottomOffset = getWindow().getDecorView().getRootWindowInsets().getSystemWindowInsetBottom(); + } + // view will be scrolled to the target position by system, + if (Math.abs(bottom - bottomOffset) < 10) { + return true; + } + return false; + } + private void registKeyboardVisible() { getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -220,7 +232,9 @@ public void onGlobalLayout() { if (!keyboardVisible) { keyboardVisible = true; } - getRootView().scrollTo(0, heightDiff); + if (!isSystemAdjustUIWhenPopKeyboard(heightDiff)) { + getRootView().scrollTo(0, heightDiff); + } } else { getRootView().scrollTo(0, 0); if (mCheckKeyboardShowNormally && !keyboardVisible) {