簡體   English   中英

在 WebView 中對齊 ImageView

[英]Align ImageView inside WebView

我需要在 WebView 的右下角對齊圖像,但圖像總是在左上角。

我已經嘗試使用本主題中的解決方案,但沒有成功: 將 ImageView 與 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"
    />

暫無
暫無

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

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