Fix status bar color in MainActivity.

This commit is contained in:
Alex Ning 2020-03-16 00:22:56 +08:00
parent fe658dd9e2
commit 751a515a7d
2 changed files with 11 additions and 1 deletions

View File

@ -40,6 +40,7 @@ public abstract class BaseActivity extends AppCompatActivity {
private boolean immersiveInterface;
private boolean changeStatusBarIconColor = true;
private boolean transparentStatusBarAfterToolbarCollapsed;
private boolean hasDrawerLayout = false;
private int systemVisibilityToolbarExpanded = 0;
private int systemVisibilityToolbarCollapsed = 0;
private CustomThemeWrapper customThemeWrapper;
@ -105,7 +106,9 @@ public abstract class BaseActivity extends AppCompatActivity {
Window window = getWindow();
View decorView = window.getDecorView();
window.setStatusBarColor(customThemeWrapper.getColorPrimaryDark());
if (!hasDrawerLayout) {
window.setStatusBarColor(customThemeWrapper.getColorPrimaryDark());
}
boolean isLightStatusbar = customThemeWrapper.isLightStatusBar();
boolean isLightNavBar = customThemeWrapper.isLightNavBar();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@ -208,6 +211,10 @@ public abstract class BaseActivity extends AppCompatActivity {
this.transparentStatusBarAfterToolbarCollapsed = true;
}
protected void setHasDrawerLayout() {
hasDrawerLayout = true;
}
protected void applyToolbarTheme(Toolbar toolbar) {
toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor());
}

View File

@ -193,6 +193,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);
setHasDrawerLayout();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@ -292,6 +294,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
protected void applyCustomTheme() {
int backgroundColor = mCustomThemeWrapper.getBackgroundColor();
drawer.setBackgroundColor(backgroundColor);
drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark());
navigationView.setBackgroundColor(backgroundColor);
appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor());
applyTabLayoutTheme(tabLayout);