Skip to content

Instantly share code, notes, and snippets.

@brinsche
Created July 22, 2015 21:59
Show Gist options
  • Save brinsche/d84fe9e7f2f0a128ec8a to your computer and use it in GitHub Desktop.
Save brinsche/d84fe9e7f2f0a128ec8a to your computer and use it in GitHub Desktop.
Toolbar shadow in coordinatorlayout pre lollipop
elevation_compat.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="@android:color/transparent"
android:startColor="#50000000" />
</shape>
styles.xml
<style name="ElevationCompatTheme">
<item name="android:visibility">visible</item>
</style>
styles.xml for api 21+
<style name="ElevationCompatTheme">
<item name="android:visibility">gone</item>
</style>
put this at the bottom of your coordinatorlayout to make ot appear on top of other views
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/elevation_compat"
android:theme="@style/ElevationCompatTheme"
app:layout_behavior="your scrolling behaviour"/>
@atengberg
Copy link

Thanks

@Perdator
Copy link

Perdator commented Oct 17, 2016

Not working. Needs to be added some addon xml to AppBarLayout that is a Toolbar wrapper:
android:background="@android:drawable/screen_background_light_transparent"
In another case View will contain primaryColor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment