I add the new material design actionbar from the new appcompat and I use the new toolbar widget. I set a custom background on the toolbar on xml but my problem is that the drop shadow from the actionbar is not displayed. Do you know how to do this?
Toolbar code
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@drawable/ab_background_textured"
app:theme="@style/MyTheme"
app:popupTheme="@style/MyTheme.Popup"/>
MyTheme style
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">#ffff8800</item>
</style>
MyTheme.Popup style
<style name="MyTheme.Popup" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColor">#ffffff</item>
</style>
Update
Like @Justin Powell suggested I add the actionBarStyle
on my theme but still there is no drop shadow.
MyTheme style(Updated)
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">#ffff8800</item>
<item name="android:actionBarStyle">@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
</style>
This is how I display the shadow:
And then the topshadow layout looks like this (adjust the 5dp to get the shadow height you want):
background_shadow.xml
toolbar_actionbar.xml
I found the solution in the Google IO app to be acceptable for myself, but saw no blog or Stackoverflow post fully explaining it. What you can do is grab their Apache 2 licensed drawer shadow asset from https://github.com/google/iosched/blob/master/android/src/main/res/drawable-xxhdpi/bottom_shadow.9.png and then in the layout of your Activity:
Whereas header shadow is
for API levels <21. Just like https://github.com/google/iosched/blob/master/android/src/main/res/values/refs.xml and https://github.com/google/iosched/blob/master/android/src/main/res/values-v21/refs.xml.
And to be elaborate, here is toolbar.xml
actionbar_background.xml
add to actionbar_style background
add to Basetheme
For pre-5.0 layouts, you can add the shadow back to the content below the toolbar by adding
foreground="?android:windowContentOverlay"
to the content's FrameLayout.For example: