英文:
I can't display floating action menu on recyclerview
问题
我想在RecyclerView对象上显示浮动操作菜单。我有一个课程活动,用于显示保存的课程。我想在其中添加浮动操作按钮,包括两个选项。当我添加新数据时,如果RecyclerView对象没有数据,我的浮动操作菜单可以正常工作,但是当RecyclerView已满时,它不像页面底部的图片那样工作。我该如何解决这个问题?
<?xml version="1.0" encoding="utf-8"?>
<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>

英文:
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>
<a href="https://resimyukle.xyz/i/1dGcfC"><img src="https://i.resimyukle.xyz/1dGcfC.png" /></a>
答案1
得分: 1
你只需将FloatingActionMenu放在RecyclerView下方,然后FloatingActionMenu将显示在顶部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>
英文:
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>
专注分享java语言的经验与见解,让所有开发者获益!



评论