Expandable FAB in LinearLayout

Viewed 22

I want to create an expandable FAB with 2 option. I want them to appear one after the other in the right corner. I tried everything, but I am not familiar with this layouts. Below I post what the xml now looks like. As you can see, there is only one FAB appear, but I want to look like this: enter image description here

enter image description here

The fragment's xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp"
    android:id="@+id/asd">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        //code

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

           //code

        </LinearLayout>

        //code

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/add_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:text="Actions"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginEnd="20dp"
            android:layout_marginBottom="20dp"
            android:layout_marginRight="20dp" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/add_person_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fabSize="normal"
            app:layout_constraintBottom_toBottomOf="@+id/add"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_gravity="end"
            android:layout_marginEnd="20dp"
            android:layout_marginBottom="20dp"
            android:layout_marginRight="20dp" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/add_alarm_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fabSize="normal"
            android:layout_gravity="end"
            android:layout_marginEnd="20dp"
            android:layout_marginRight="20dp" />


    </LinearLayout>

    </LinearLayout>

</LinearLayout>
0 Answers
Related