I use a very simple style to format my Toolbar, I use android:elevation to display a shadow under the Toolbar like this:
<style
name="AppToolbarTheme"
parent="AppTheme">
<item name="android:background">@color/colorPrimary</item>
<item name="android:titleTextColor">@android:color/white</item>
<item name="android:elevation">4dip</item>
</style>
And I'm applying it simply like that:
<Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppToolbarTheme"/>
The shadow displays under the toolbar like I want, howerver it is also somehow applied to the title of the toolbar which looks very weird:
Remove <item name="android:elevation">4dip</item>
from style and put it in toolbar
xml
<Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppToolbarTheme"
android:elevation="4dp"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With