2012-10-30 4 views
1

나는 안드로이드에서 초보자입니다. 나는 webview에 이미지를 오버레이하고 싶다. 나는 webview와 imageview와 Framelayout를 사용합니다. 그것은 올바르게 작동합니다. 그러나 비디오가 웹 뷰에서 재생 될 때 이미지는 표시되지 않습니다. 플레이어 내부에 이미지를 표시하는 방법? 아래 코드를 언급했다. 제발 도와주세요오버레이 방법 imageview on webview

<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 > 
+3

상대 레이아웃을 사용하십시오. – AppMobiGurmeet

+0

잘 동작합니다. 웹 뷰에서는 비디오를 재생하지만 플레이어 내부에는 이미지가 표시되지 않지만 이미지는 플레이어 외부에 표시됩니다. 이미지를 표시 할 수 있습니다. 선수들? – dran

+0

을 따르십시오. http://stackoverflow.com/questions/4901408/in-android-how-to-display-one-view-as-overlay-on-top-of-another-view – AppMobiGurmeet

답변

0

안녕하세요 저는 심지어 몇 개의 버튼을 이미지와 진행률 표시 줄을 webview에 보관했습니다. 여기에 코드 스 니펫이 있습니다.

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

그러나 인터페이스 빌더를 사용하면이 작업을 수행 할 수 있습니다.

먼저 웹 뷰를 레이아웃 파일로 드래그 앤 드롭합니다.

나중에 이미지 또는 이미지 버튼을 추가해보십시오.

희망이 도움이됩니다.