android 网页视图中的浮动操作按钮

Floating Action Button in android webview

我已经创建了一个带有 webview 的简单 android 应用程序来展示我的网站,所以现在我正在尝试添加 FAB,以便用户可以使用该按钮共享文章。无论我把代码放在哪里,当我把它放在 webview 中时,它要么崩溃,要么因为它滚动而没有用,我在下面分享我的代码,你能帮忙对齐吗,我希望 FAB 成为右下角的粘性按钮应用程序。

    <?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"
    tools:context=".MainActivity">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout_behavior="@string/appbar_scrolling_view_behavior">

        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </WebView>


    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>


    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        style="?android:attr/progressBarStyle"
        />

</RelativeLayout>

你能指导我正确的做法吗,之后我必须更改 JAVA 文件。

试试这个,

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical">

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="75dp"
        android:orientation="horizontal"
        android:elevation="6dp"
        android:layout_alignParentBottom="true">

        <YOUR_FAB_HERE
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_marginEnd="25dp"
            android:visibility="visible"
            app:srcCompat="@drawable/ic_file_upload_white_24dp"
            tools:ignore="VectorDrawableCompat" />

    </RelativeLayout>

      <--- your additional layout here ----->

</RelativeLayout>