Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead

I'm having this issue when I applied the toolbar into my app and it crashed when I try to run the app.I used all previous post but no luck. Here is my code :

Style.xml

<style name="ToolBarStyle" parent="@style/Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>       

 </style> 

I tried parent="@style/Theme.AppCompat.Light.NoActionBar" but not worked.

Toolbar.xmal

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ToolBarStyle" />

Manifest.axml

    <application android:label="Capzure" android:theme="@style/ToolBarStyle" android:icon="@drawable/Icon"></application>

Thank you.

like image 690
Uddhao Pachrne Avatar asked Jun 05 '15 15:06

Uddhao Pachrne


1 Answers

Your theme should look like this, and remove @style/:

<style name="MyMaterialTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    ...
</style>

Then, do not define the theme in <application/> tag. Define it only with activity you want to use the material design theme, i.e. in <activity> tag.

If your activity extends PreferenceActivity, AppCompatActivity, or ActionBarActivity, which you want to begin the transaction with PreferenceFragment, change your theme to:

<style name="MyMaterialTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">true</item>
    ...
</style>

And remove this line from your Toolbar:

android:theme="@style/ToolBarStyle" 
like image 58
Anggrayudi H Avatar answered Oct 18 '22 23:10

Anggrayudi H