Preamplifier Shadow FloatingActionButton

I want to make my FloatingActionButton lot bigger with custom width and height. I find out that this is possible only if I add this as a child in FrameLayout or in CoordinatorLayout . On Lollipop and Marshmallow, it looks good. But on pre-Lollipop, the shadow from FloatingActionButton very strange. Is this a bug from Android, or did I do something wrong?

 <android.support.design.widget.CoordinatorLayout android:id="@+id/help_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> <android.support.design.widget.FloatingActionButton android:id="@+id/my_btn" android:layout_width="150dp" android:layout_height="150dp" android:layout_gravity="center" android:src="@mipmap/ic_launcher" /> </android.support.design.widget.CoordinatorLayout> 

I also tried adding app:borderWidth="0dp" , but no luck.

Here's what it looks like in Kitkat:

Kitkat

+5
source share
3 answers

The Fab button is available in two sizes by default. Normal (56dp), Mini (40dp)

But you can redefine these values ​​by adding the following code in the dimensions.xml (below the values).

 <dimen name="design_fab_size_normal">150dp</dimen> <dimen name="design_fab_size_mini">30dp</dimen> 
+2
source

I believe this is caused by these two lines:

 android:layout_width="150dp" android:layout_height="150dp" 

Try to install:

 android:layout_width="match_parent" android:layout_height="match_parent" 

Then add:

 app:fabSize="normal" 

So the final xml will be:

 <android.support.design.widget.CoordinatorLayout android:id="@+id/help_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> <android.support.design.widget.FloatingActionButton android:id="@+id/my_btn" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:src="@mipmap/ic_launcher" app:fabSize="normal"/> </android.support.design.widget.CoordinatorLayout> 
0
source

You must install

 android:layout_width= "wrap_content" android:layout_height= "wrap_content" 

and fabSize on mini (40dp) or normal (56dp). If you want a different size of the fab button, you must scale the button.
For instance. if you want 48dp button size you should add

 app:fabSize="mini" android:scaleX=1.2 android:scaleY=1.2 

Also, if you want to keep the image size set to android: scaleType = "center"

0
source

All Articles