Search code examples
javaandroidxmlandroid-recyclerviewfloating-action-button

I can't display floating action menu on recyclerview


I want to display floating action menu on recyclerview object.I have a lesson activity that display to saved lesson. I want to add floating action button its include 2 selection. When i added new dataif recylverview object is no have data my floating action menu is working good but when recyclerview is full its not working like the picture bottom of page. What can i do solved this problem ?

<RelativeLayout 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"
    android:layout_gravity="center"
    android:background="@drawable/bg_login"
    tools:context=".MainActivity">

        <com.github.clans.fab.FloatingActionMenu
            android:id="@+id/floatingActionMenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_margin="16dp"
            app:menu_backgroundColor="@android:color/transparent"
            app:menu_fab_label=""
            app:menu_openDirection="up"
            app:menu_showShadow="true">

            <com.github.clans.fab.FloatingActionButton
                android:id="@+id/floatingAddButtonLesson"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fab_label="Ders Ekle"
                app:fab_size="mini"
                app:srcCompat="@drawable/ic_add"
                tools:ignore="VectorDrawableCompat" />

            <com.github.clans.fab.FloatingActionButton
                android:id="@+id/floatingAddButtonLesson2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fab_label="Toplam Kaç Soru Çözdüm"
                app:fab_size="mini"
                app:srcCompat="@drawable/ic_add"
                tools:ignore="VectorDrawableCompat" />


        </com.github.clans.fab.FloatingActionMenu>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:id="@+id/rvLesson"
        android:layout_height="wrap_content"/>
</RelativeLayout>


Solution

  • You just need to place FloatingActionMenu below the RecyclerView, then FloatingActionMenu will show on top RecyclerView

    <RelativeLayout 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"
        android:layout_gravity="center"
        android:background="@drawable/bg_login"
        tools:context=".MainActivity">
    
            <androidx.recyclerview.widget.RecyclerView
                android:layout_width="match_parent"
                android:id="@+id/rvLesson"
                android:layout_height="wrap_content"/>
    
            <com.github.clans.fab.FloatingActionMenu
                android:id="@+id/floatingActionMenu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_margin="16dp"
                app:menu_backgroundColor="@android:color/transparent"
                app:menu_fab_label=""
                app:menu_openDirection="up"
                app:menu_showShadow="true">
    
                <com.github.clans.fab.FloatingActionButton
                    android:id="@+id/floatingAddButtonLesson"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:fab_label="Ders Ekle"
                    app:fab_size="mini"
                    app:srcCompat="@drawable/ic_add"
                    tools:ignore="VectorDrawableCompat" />
    
                <com.github.clans.fab.FloatingActionButton
                    android:id="@+id/floatingAddButtonLesson2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:fab_label="Toplam Kaç Soru Çözdüm"
                    app:fab_size="mini"
                    app:srcCompat="@drawable/ic_add"
                    tools:ignore="VectorDrawableCompat" />
    
    
            </com.github.clans.fab.FloatingActionMenu>
    
    </RelativeLayout>