Fix DrawerLayout in MainActivity has extra background color in immersive interface on Android 11.

This commit is contained in:
Alex Ning 2020-10-19 12:13:43 +08:00
parent 658af22c04
commit 1283ad62bb

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
@ -247,6 +248,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
if (isImmersiveInterface()) {
drawer.setStatusBarBackgroundColor(Color.TRANSPARENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false);
drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
@ -266,6 +268,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
linearLayoutBottomAppBar.getPaddingTop(), 0, navBarHeight);
navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight);
}
} else {
drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark());
}
}
@ -343,7 +347,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
protected void applyCustomTheme() {
int backgroundColor = mCustomThemeWrapper.getBackgroundColor();
drawer.setBackgroundColor(backgroundColor);
drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark());
int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);