【问题标题】:Align ImageView inside WebView在 WebView 内对齐 ImageView
【发布时间】:2020-05-29 20:35:41
【问题描述】:

我需要在 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>

【问题讨论】:

    标签: java android android-studio webview


    【解决方案1】:

    你可以试试下面的代码来实现——

    <?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"
        />
    

    【讨论】:

      猜你喜欢
      • 2018-07-07
      • 1970-01-01
      • 2018-06-30
      • 2020-08-30
      • 1970-01-01
      • 2014-10-15
      • 1970-01-01
      • 2014-07-11
      • 2014-03-05
      相关资源
      最近更新 更多