<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" tools:ignore="HardcodedText"> <!-- This will be the parent Floating Action Button --> <!-- After the implementation the Floating Action Button at the bottom right corner --> <!-- After clicking the above button the following two buttons will pop up. So this button is considered as parent FAB --> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/add_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end" android:layout_marginEnd="16dp" android:layout_marginBottom="16dp" android:src="@drawable/ic_add_black_24dp" app:fabSize="normal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> <!-- Floating action button for add alarm --> <!-- Make sure that you are constraining this button to the parent button --> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/add_alarm_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="24dp" app:fabSize="normal" app:layout_constraintBottom_toTopOf="@+id/add_fab" app:layout_constraintEnd_toEndOf="@+id/add_fab" app:layout_constraintStart_toStartOf="@+id/add_fab" app:srcCompat="@drawable/ic_add_alarm_black_24dp" /> <!-- Action name text for the add alarm button --> <!-- Make sure that you are constraining this Text to the add Alarm FAB button --> <TextView android:id="@+id/add_alarm_action_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:text="Add Alarm" app:layout_constraintBottom_toBottomOf="@+id/add_alarm_fab" app:layout_constraintEnd_toStartOf="@+id/add_alarm_fab" app:layout_constraintTop_toTopOf="@+id/add_alarm_fab" /> <!-- Floating action button for add person --> <!-- Make sure that you are constraining this button to the add Alarm FAB button --> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/add_person_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="24dp" app:fabSize="normal" app:layout_constraintBottom_toTopOf="@+id/add_alarm_fab" app:layout_constraintEnd_toEndOf="@+id/add_alarm_fab" app:layout_constraintStart_toStartOf="@+id/add_alarm_fab" app:srcCompat="@drawable/ic_person_add_black_24dp" /> <!-- Action name text for the add person button --> <!-- Make sure that you are constraining this Text to the add Person FAB button --> <TextView android:id="@+id/add_person_action_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:text="Add Person" app:layout_constraintBottom_toBottomOf="@+id/add_person_fab" app:layout_constraintEnd_toStartOf="@+id/add_person_fab" app:layout_constraintTop_toTopOf="@+id/add_person_fab" /> </androidx.constraintlayout.widget.ConstraintLayout>
how to set image / vector assets in floating action Button
- answer :
app:fabCustomSize="40dp"set size according your need
- fab default size 56dp X 56dp