I'm trying to get a 4dp
elevation on a button in a sample app and I can't seem to get any shadow to show up.
This is my code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:clipChildren="false"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me"
android:background="@drawable/myrect"
android:elevation="4dp"/>
</LinearLayout>
With my background drawable being:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#336699" />
<corners android:radius="5dp" />
</shape>
My app.gradle is:
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
...
}
This is the result:
I did see other posts with the same issue like this one: Elevation on Android Lollipop not working. They all point to a semi-transparent background as the issue, but as you can see here I'm using a full opacity one.
Any idea of what I'm missing?