How do I style appcompat-v7 Toolbar like Theme.AppCompat.Light.DarkActionBar?

后端 未结 7 1510
猫巷女王i
猫巷女王i 2020-11-30 16:46

I\'m trying to recreate the look of Theme.AppCompat.Light.DarkActionBar with the new support library Toolbar.

If I choose Theme.AppCompat.Light

7条回答
  •  北海茫月
    2020-11-30 17:40

    Edit: After updating to appcompat-v7:22.1.1 and using AppCompatActivity instead of ActionBarActivity my styles.xml looks like:

    
    

    Note: This means I am using a Toolbar provided by the framework (NOT included in an XML file).

    This worked for me:
    styles.xml file:

    
    

    Update: A quote from Gabriele Mariotti's blog.

    With the new Toolbar you can apply a style and a theme. They are different! The style is local to the Toolbar view, for example the background color. The app:theme is instead global to all ui elements inflated in the Toolbar, for example the color of the title and icons.

提交回复
热议问题