How to change Floating Action Button Size in Android

In android, there are different ways to change floating action button size in android.

We will show the code snippet for each method below.

Using dimens.xml file

In your android project values directory, we will create a dimens.xml file which we can use to override the default android attributes values.

<dimen name="design_fab_size_normal" tools:override="true">90dp</dimen>
<dimen name="design_fab_size_mini" tools:override="true">30dp</dimen>

As can be seen above, the default values of design_fab_size_normal and design_fab_size_minihave been changed

Using app:fabCustomSize

The simplest way to achieve this in XML code is my using FAB app:fabCustomSizeattribute as show below.

<android.support.design.widget.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        app:fabCustomSize="80dp"
        app:srcCompat="@android:drawable/btn_dialog" />

In the next code snippet, you will learn different ways you can use to increase the size of android floating action button in android.

 

 

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.