Search code examples
javaandroidandroid-layoutfloating-action-button

How can i declare two different userdefined size for Floating Action Button inside dimens.xml?


i wish to add two different size of floating action button within my program. The best solution i found is to edit default size from dimens.xml as follows

<dimen name="design_fab_image_size tools:override="true">36dp</dimen>

But i need two different size for two floating action button. how can i achieve that.

below is my xml code for 2 button

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="105dp"
        android:layout_height="121dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="left|bottom"
        android:layout_marginRight="1dp"
        android:layout_marginBottom="-1dp"
        android:src="@drawable/alarm01"
        android:scaleType="center"

        android:visibility="visible"
        app:backgroundTint="#00FFFFFF"
        app:borderWidth="0dp"


        app:elevation="0dp"
        app:rippleColor="?android:attr/colorActivatedHighlight"
        />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab1"
        android:layout_width="105dp"
        android:layout_height="121dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="left|bottom"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="-1dp"
        android:outlineProvider="none"
        android:scaleType="center"

        android:src="@drawable/mic01"
        android:visibility="gone"

        app:backgroundTint="#00FFFFFF"
        app:borderWidth="0dp"
        app:elevation="0dp"
        app:rippleColor="?android:attr/colorActivatedHighlight" />

Solution

  • I just have found out that i do not have to edit the default size from dimen xml file . instead there is a feature to edit size directly on each fab button using following code,which works great.

    app:maxImageSize="110dp"