Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an "image only" floating action button

I have an image as below.

enter image description here

When I use it to make a floating action button, the button looks like this.

enter image description here

I don't want the pink margin. I only want my image to be shown. What should I do?

I also want the size of my image to be the outer circle not the inner one.

Here is my code:

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_refresh" />
like image 543
Jeffrey Chen Avatar asked Jan 10 '16 10:01

Jeffrey Chen


1 Answers

Im not sure that this solution as acceptable, but it works;

You can override image size dimension for nested image in FAB. Just add to your dimens file:

<dimen tools:override="true" name="design_fab_image_size">56dp</dimen> (I used 56dp cause fab size in guidelines is 56dp)

tools:override="true" - this is the thing why I suppose that this solution is not good, cause "design_fab_image_size" - is final, and you should insist on overriding :)

like image 60
Алексей Юр Avatar answered Oct 22 '22 06:10

Алексей Юр