Do not request Window.FEATURE_ACTION_BAR issue Do not request Window.FEATURE_ACTION_BAR issue android android

Do not request Window.FEATURE_ACTION_BAR issue


Using Theme.AppCompat.Light tells Android that you want the framework to provide an ActionBar for you. However, you are creating your own ActionBar (a Toolbar), so you are giving the framework mixed signals as to where you want the ActionBar to come from.

Since you are using a Toolbar, you want Theme.AppCompat.Light.NoActionBar.

The next step is to make sure your Toolbar is styled correctly, which seems to be where you are running into issues. To style your Toolbar like an ActionBar using the colors you defined for your theme, you need to provide a theme like so:

<android.support.v7.widget.Toolbar    android:layout_height="wrap_content"    android:layout_width="match_parent"    android:minHeight="?attr/actionBarSize"    app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

See the "styling" section for the Toolbar widget on this Android Developers blog post for more information.


Assuming you got this lines in styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">    <item name="colorPrimary">@color/colorPrimary</item>    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>    <item name="colorAccent">@color/colorAccent</item></style>

Add these extra lines after:

<style name="AppTheme.NoActionBar">    <item name="windowActionBar">false</item>    <item name="windowNoTitle">true</item></style>

Then add this to your activity in manifest:

<activity android:name=".activity.YourActivity"          android:theme="@style/AppTheme.NoActionBar"><!-- ADD THIS LINE -->

That was best solution for me after checking tutorials and other solutions


In my case, I created a new activity and forgot to define it's app:theme in AndroidManifest.xml:

 <activity        android:name=".HistoryActivity"        android:label="History"        android:theme="@style/AppTheme.Primary"></activity>