To create a circular icon based on the vector icons of Android Studio, I do the following:
<?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="@color/colorAccent"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_select"
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:top="20dp"/>
</layer-list>
The result is:
That's what I want to do in a dynamic and customizable way:
- Allow to change the color of the circle
- Assign an icon
- Tint of the icon
More or less reproduce the new style of Android P on the screen set, which leaves the icon in a circle.
I had thought of creating a Bitmap
filled in a color, insert the icon in the middle and then with the library glide4
transform into format ciruclar with circleCropTransform
, but I would like not to depend on glide and if it can be done only with java and the layers-xml