1

I am beginner in android . I want to overlay a image on webview . I use the Framelayout with webview and imageview .It works correctly. But when the videos are played in the webview the image is not displayed. how to display a image inside a player ? I mentioned my code below . please help me

<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 >
dran
  • 245
  • 1
  • 6
  • 16
  • 3
    use Relative layout.It will work – AppMobiGurmeet Oct 30 '12 at 11:37
  • It works fine .I play the video in webview .but the image is not displayed inside a player .but the image is displayed at outside a player .It is possible to display a image in the players? – dran Oct 30 '12 at 11:43
  • please follow http://stackoverflow.com/questions/4901408/in-android-how-to-display-one-view-as-overlay-on-top-of-another-view – AppMobiGurmeet Oct 30 '12 at 11:50

1 Answers1

0

Hi I even kept few buttons an image and progress bar on webview. here is the code snippet .

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

However this can be achived by using the Interface builder.

First drag and drop the webview onto the layout file.

Later try adding the images or image buttons.

Hope this helps.

Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71