在 WebView 中对齐 ImageView

Align ImageView inside WebView

我需要将图像对齐到 WebView 的右下角,但图像总是在左上角。

我已经尝试使用本主题中的解决方案,但没有成功:Align ImageView to bottom Right of LinearLayout

还有其他方法吗?

我的XML:

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

    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView android:id="@+id/imageBack"
            android:layout_height="50dp"
            android:layout_width="50dp"
            android:src="@drawable/logo_mosaic"
        />
    </WebView>
</LinearLayout>

您可以尝试下面的代码来实现 -

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

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


    </WebView>
    <ImageView android:id="@+id/imageBack"
               android:layout_height="50dp"
               android:layout_gravity="bottom|right"
               android:layout_width="50dp"

               android:src="@drawable/logo_mosaic"
    />