android – Is it possible to have more than two Floating Action Buttons?


I’m struggling with something that should be pretty straight-forward, and now I don’t know if it is some undocumented limitation of the FAB element. I have three identical FABs in one screen inside an horizontal LinearLayout, but the third one doesn’t show its icon.

enter image description here

Here’s the code for that:

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_centerInParent="true">

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/gallery_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dialog_btn_spacing"
            android:layout_marginEnd="@dimen/dialog_btn_spacing"
            android:src="https://stackoverflow.com/@drawable/ic_photo_camera"
            app:backgroundTint="#FF5252"
            app:fabCustomSize="80dp" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/camera_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dialog_btn_spacing"
            android:layout_marginEnd="@dimen/dialog_btn_spacing"
            android:src="https://stackoverflow.com/@drawable/ic_photo_camera"
            app:backgroundTint="#4CAF50"
            app:fabCustomSize="80dp" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/text_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dialog_btn_spacing"
            android:layout_marginEnd="@dimen/dialog_btn_spacing"
            android:src="https://stackoverflow.com/@drawable/ic_photo_camera"
            app:backgroundTint="#21BFF3"
            app:fabCustomSize="80dp" />

    </LinearLayout>

Even more, if I add an additional one to the LinearLayout, the result is exactly the same, the fourth one not appearing at all. Is there some kind of limitations for the number of FABs to show? I’m not manipulating the FABs by code in any way, only adding a click listener to each of them. The icons are vector drawables directly imported from the Material icons library (and for the sake of this example, I put the same one for the three of them).

I’m not sure what the specific problem might be, but it is giving me a headache…