I\'m writing my own toolbar with an android.support.v7.widget.Toolbar widget and I want to put as much as possible into a styles.xml in my res folder.
Part of a file
Use Android
replace app
in style file:
<style name="toolbar_dark">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@color/myPrimary</item>
<item name="android:theme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="android:popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="android:contentInsetStart">0dp</item>
</style>
You can't use an app namespace in your style file, and you should refer to style
attribute wihtout app namespace in your layout.
You can do somenthing like this:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar_show_addresses_simple"
style="@style/toolbar_dark" >
Style:
<style name="toolbar_dark" parent="Widget.AppCompat.Toolbar">
<item name="android:background">@color/green</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark</item>
</style>