0

I have a problem when I set the theme on my app to Theme.AppCompat.Light.DarkActionBar. For some reason there is a white bar above my actionbar. How do I remove this? Unfortunately, I can't show you a picture of it as I'm not allowed to post pictures yet. But it's just a white empty bar with the same title as the action bar has.

My onCreate method looks like this as of now:

@Override
protected void onCreate(Bundle savedInstanceState) {
    if(PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getString("theme_preference", "1").equals("AppTheme")) {
        setTheme(R.style.AppTheme);
    } else {
        setTheme(R.style.DarkTheme);
    }
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main_transmit);

AppTheme is Theme.AppCompat.Light.DarkActionBar and DarkTheme is Theme.AppCompat.

How do I remove the white bar that appears?

2 Answers2

0

I can't be sure without a picture but it sounds like you have the problem I just figured out how to fix. The white bar is the status bar. Starting in android 5.0, android gives the status bar the same color as colorPrimaryDark in the app's theme. If colorPrimaryDark equals white, as it did and needs to be in my case, all of the white icons blend in and create a solid, ugly white bar above the actionbar. This thread: How to change the status bar color in android contains some ways to change the color manually. I chose to use this:

if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(getResources().getColor(android.R.color.black));
    }
Community
  • 1
  • 1
0

The problem with two actionbars disappeared when I changed the name of the AppCompat.Light theme from AppTheme to LightTheme. I have no idea why android behaved the way it did just because of what the theme was called, but it did. I changed the name from AppTheme to LightTheme and the problem disappeared.