First create a .xml form resource, call ring.xml on it and put the following into it:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadiusRatio="1" android:shape="ring" android:thicknessRatio="1" android:useLevel="false"> <solid android:color="#FFF"/> <stroke android:width="5dp" android:color="#000"/> </shape> </item> <item> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_cast_light"/> </item> </layer-list>
You will need to play with the thickness and innerRadius attributes to fix this, but it must be done! Also, the source of the bitmap is just a filler, you want to place your image F.
Then, when you declare your factory, refer to your ring as follows:
android:background="@drawable/ring"
OR
In your Java code, follow these steps:
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setBackgroundResource(R.drawable.ring);
Hope this helps!
Joshua king
source share