Home > OS >  Add a button when image or video loads in a webview
Add a button when image or video loads in a webview

Time:05-11

I want to add a button when image or video loads in a WebView. Like this in Images given below.

See this

See this

CodePudding user response:

add drawable as per your need

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

    <WebView
        android:id="@ id/webView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@ id/fab_more"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:src="@drawable/ic_download"
        app:backgroundTint="@android:color/holo_red_dark"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.95"
        app:layout_constraintStart_toStartOf="@ id/webView"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.65999997"
     
        app:tint="@color/white"
        tools:ignore="ContentDescription" />

</androidx.constraintlayout.widget.ConstraintLayout>
  • Related