Home » Android » themes – dark activities with android compat without actionbar?

themes – dark activities with android compat without actionbar?

Posted by: admin June 15, 2020 Leave a comment

Questions:

How can I implement dark screens without actionbar in the appcompat theme? I have implemented the navigation drawer, where the theme comes from style.xml.

Here’s my current theme:

<resources>
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentStatus">true</item>
  </style>
</resources>
How to&Answers:

Simple.

parent="Theme.AppCompat.NoActionBar"

Answer:

You can do this in your onCreate method of Activity, like this:

ActionBar actionBar = getActionBar();
if (actionBar != null) {
        actionBar.hide();
}

Answer:

This would be your styles.xml

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>