簡體   English   中英

android webview 中的浮動操作按鈕

[英]Floating Action Button in android webview

我用 webview 創建了一個簡單的 android 應用程序來展示我的網站,所以現在我正在嘗試添加 FAB,以便用戶可以使用該按鈕共享文章。 無論我把代碼放在哪里,當我把它放在 webview 里面時,它要么崩潰,要么就沒有用,因為它會滾動,我在下面分享我的代碼,你能幫忙解決 alignment 嗎,我希望 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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM