I am trying to move my layout whenever the keyboard appears.
The development device is a xiaomi mi 9 lite running miui 12.0.10 and Android 10 QKQ1.
- On my development device everything works as I expect it to work.
- On the emulator (Pixel 3 API 30, Android 11) it does not work
- On a Xiaomi Mi 11 Lite (MIUI12.5.6, Android 11 RKQ1) it does not work
This is my manifest
android:windowSoftInputMode="stateVisible|adjustResize"
This is my BaseTheme
<style name="App.Theme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
This is the skeleton of (one of the UI that does not scroll):
<androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView>
<EditText>
</androidx.constraintlayout.widget.ConstraintLayout>
I think the culprit is this code but I don't know how to fix this issue. This comes from here
private void makeTransparentStatusBar() {
Window window = getWindow();
if (Build.VERSION.SDK_INT <= 29) {
window.setStatusBarColor(Color.TRANSPARENT);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE);
} else {
window.setStatusBarColor(Color.TRANSPARENT);
// Making status bar overlaps with the activity
WindowCompat.setDecorFitsSystemWindows(window, false);
//This sadly also overlapps the bottom navigation bar (which we do not want). Fix this
ViewCompat.setOnApplyWindowInsetsListener(b.getRoot(), (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
// Apply the insets as a margin to the view. Here the system is setting
// only the bottom, left, and right dimensions, but apply whichever insets are
// appropriate to your layout. You can also update the view padding
// if that's more appropriate.
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) b.getRoot().getLayoutParams();
params.setMargins(params.leftMargin, params.topMargin, params.rightMargin, insets.bottom);
b.getRoot().setLayoutParams(params);
// Return CONSUMED if you don't want want the window insets to keep being
// passed down to descendant views.
return WindowInsetsCompat.CONSUMED;
});
}
}