当我们滚动时,youtube视频播放器与其他布局重叠

时间:2012-02-16 07:25:13

标签: android youtube android-webview

我正在开发一个可以使用iframe在webview中播放youtube视频的应用程序。 我的代码如下:

String summary = "<iframe height='"
            +  displayWidth 
            + "' width='"
            + 800
            + "' frameborder='0' src='http://www.youtube.com/embed/ZfekaIW6esA?rel=0'></iframe>";

    if (flashInstalled) {
        mWebView.loadData(summary, "text/html", null);
        container.addView(mWebView);
    } else {
        alert.setMessage("Flash player is not installed on the device!");
        alert.show();
    }

它的工作正常但是当我缩放它并滚动它然后它将重叠其他布局 看看我的屏幕截图

before zoom and scroll

after scroll the webview

请给我更好的解决方案。 thanx

2 个答案:

答案 0 :(得分:1)

我认为你的iframe宽度和高度超过了Webview的宽度和高度。减少Iframe的大小。如果您想要更大的尺寸,请增加webview的大小。

    

    <RelativeLayout
        android:id="@+id/titlebarlayout"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:background="@drawable/titlebar2" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:background="@drawable/searchmap" >
        </Button>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="10dp"
            android:background="@drawable/searchmap" >
        </Button>
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/titlebarlayout" >

        <RelativeLayout
            android:id="@+id/webviewlayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <android.webkit.WebView
                android:id="@+id/webView1"
                android:layout_width="fill_parent"
                android:layout_height="280dp" >
            </android.webkit.WebView>

            <TextView
                android:id="@+id/textview1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/webView1"
                android:text="Chasing a target of 237 to record their third win on the trot, India needed nine runs off the last over bowled by Lasith Malinga, but Sri Lanka missed the chance to dismiss Dhoni in the fourth ball of the over when the bowler fluffed a simple run out chance; and the skipper then took three runs off the last delivery to leave Sri Lanka still searching for their first win in the tournament. There was some drama even after the last delivery as the umpires checked if the batsmen had ran one short, but replays showed they hadn&apos;t and the match ended in a tie. As an aside, Malinga had a five ball over in India&apos;s 30th over of the innings, and it is anyone&apos;s guess if the result would have been different had the error been spotted.


India stuck to the rotational policy with Sachin Tendulkar coming in for Virender Sehwag, who had a back spasm; while Irfan Pathan made another comeback as he replaced Zaheer Khan, who had a problem with his right calf. Tendulkar hit two boundaries in his 24-ball 15, but never looked comfortable in the middle, and he was the first Indian batsman to be dismissed when he edged an angled delivery around the off stump from Nuwan Kulasekara to Kumar Sangakkara behind the stumps. Tendulkar&apos;s failure is bound to be blamed on the rotational policy by its detractors, who feel the rhythm of the batsmen is disrupted.
                " >
            </TextView>
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

答案 1 :(得分:0)

我希望你这样问这个

Main Screen After Scrolling
以下代码可能会帮助您,

&lt;?xml version =“1.0”encoding =“utf-8”?&gt;
&lt; RelativeLayout xmlns:android =“http://schemas.android.com/apk/res/android”
android:layout_width =“fill_parent”
android:layout_height =“fill_parent”
android:background =“#FFF”
android:orientation =“vertical”&gt;
&lt; ImageView
android:id =“@ + id / imageView1”
android:layout_width =“fill_parent”
android:layout_height =“40dp”
android:layout_alignParentTop =“ true“
android:layout_centerHorizo​​ntal =”true“
android:src =”@ drawable / bg“/&gt;

&lt; ScrollView
android:id =” @ + id / scrollView1“
android:layout_width =”match_parent“
android:layout_above =”@ + id / imageView“
android:layout_height =”fill_parent“
android:layout_below =“@ + id / imageView1”&gt;
&lt;! - 滚动视图只能容纳一个“孩子”
如果你有一个以上的孩子,那么创建一个虚拟布局<里面滚动视图 - &gt;

&lt ;! - 添加任意数量的孩子 - &gt;

&lt; android.webkit.WebView
android:id =“@ + id / webView1“
android:layout_width =”match_parent“
android:layout_height =”match_parent“
android:layout_alignParentTop =”true“&gt;
&lt; /android.webkit.WebView>

&lt ;! - 添加任意数量的孩子 - &gt;

&lt; / ScrollView&gt;


&lt; ImageView
android:id =“@ + id / imageView”
android:layout_width =“fill_parent”
android:layout_height =“40dp”
android:layout_alignParentBottom =“true”
android:layout_alignParentLeft =“true”
android:src =“@ drawable / bg”/&gt;
&LT; / RelativeLayout的&GT;