I wanted to set a custom drawable to be the android:src of FloatingActionButton in this layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sscce="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
sscce:fabSize="normal"
android:src="@drawable/fab_drawable" />
</LinearLayout>
I was expecting something like:
But I got:
Here is the custom layer-list drawable, which contains a few shape drawables:
res/drawable/fab_drawable.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval">
<solid android:color="#1AFF00" /> <!-- green -->
<size android:width="150dp"
android:height="150dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#FC00FF" /> <!-- pink -->
<size android:width="100dp"
android:height="100dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="#0040FF" /> <!-- blue -->
<size android:width="40dp"
android:height="40dp" />
</shape>
</item>
<item>
<shape android:shape="oval" >
<stroke android:width="3dp"
android:color="#FF0000"/> <!-- red -->
<solid android:color="#FFBF00" /> <!-- yellow -->
<size android:width="24dp"
android:height="24dp" />
</shape>
</item>
</layer-list>