Usually icons are set for floating action buttons, but I need to set an image, so I can make a circular image.
I added it to the project (using Android Studio-> New
If you are setting a rounded png image, work around for this is to extend the floatingActionButton class then override the on onMeasure method and set the padding to 0, and scaleType To centerCrop
public class FloatingImageButton extends FloatingActionButton {
public FloatingImageButton(Context context) {
super(context);
}
public FloatingImageButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setPadding(0, 0, 0, 0);
setScaleType(ScaleType.CENTER_CROP);
}
}
xml sample
output