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

前端 未结 1 445
伪装坚强ぢ
伪装坚强ぢ 2020-12-15 06:51

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 :

S

相关标签:
1条回答
  • 2020-12-15 07:28

    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" 
    
    0 讨论(0)
提交回复
热议问题