【问题标题】:How to Overlay imageview On Webview android如何在 Webview android 上覆盖 imageview
【发布时间】:2012-10-30 11:26:54
【问题描述】:

我是 android 的初学者。我想在 webview 上叠加图像。我将 Framelayout 与 webview 和 imageview 一起使用。它可以正常工作。但是当视频在 web 视图中播放时,图像不会显示。如何在播放器中显示图像?我在下面提到了我的代码。请帮帮我

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0dp"
    android:layout_margin="0dp">

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="0dp"
    android:padding="0dp" 
    android:scaleType="center"/>

 <ImageView
     android:id="@+id/imageview"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal|center"
     android:contentDescription="@string/webviewexample"
     android:src="@drawable/image"/>

</FrameLayout >

【问题讨论】:

  • 使用相对布局。它会工作
  • 它工作正常。我在 webview 中播放视频。但图像未显示在播放器内。但图像显示在播放器外部。可以在播放器中显示图像吗?

标签: android android-layout webview imageview


【解决方案1】:

嗨,我什至在 webview 上保留了几个按钮作为图像和进度条。这是代码sn-p。

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

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

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="80dip"
        android:src="@drawable/homepageheader"
        android:layout_marginTop="0dip" />

   <ImageButton
        android:id="@+id/button_back"
        android:layout_width="36dp"
        android:layout_height="44dp"
        android:layout_marginLeft="20dip"
        android:background="@android:color/transparent"
       android:layout_marginTop="22dip"
        android:src="@drawable/backbtn" /> 

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal" />

 <ImageButton
       android:id="@+id/button_refresh"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/refresh_icon" 
        android:layout_gravity="right"
        android:layout_marginRight="20dip"
        android:layout_marginTop="22dip"
        android:background="@android:color/transparent"/> 

</FrameLayout>

但是,这可以通过使用界面生成器来实现。

首先将 webview 拖放到布局文件上。

稍后尝试添加图像或图像按钮。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多