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

发布于 2025-01-05 17:38:58 字数 746 浏览 3 评论 0 原文

我正在开发一个应用程序,可以使用 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();
    }

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

缩放和滚动之前

滚动网页视图后

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

i am developing an application which can play youtube video in webview using iframe.
my code is given below :

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();
    }

its working fine but when i zoom it and scroll it then it will overlaps the other layout
Look at my screen shots

before zoom and scroll

after scroll the webview

plz give me the better solution for this. thanx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜司空 2025-01-12 17:38:58

我认为你的 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't and the match ended in a tie. As an aside, Malinga had a five ball over in India's 30th over of the innings, and it is anyone'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'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>

I think your Iframe width and height are more than Webview width and height. Decrease the size of Iframe. If you want a larger size, increase the size of 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't and the match ended in a tie. As an aside, Malinga had a five ball over in India's 30th over of the innings, and it is anyone'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'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>
泼猴你往哪里跑 2025-01-12 17:38:58

我希望你是这样问的

Main Screen
滚动后

下面的代码可能会帮助您,

<?xml version =“1.0”encoding =“utf-8”?>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:orientation="vertical" >
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" />

android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_above="@+id/imageView"
android:layout_height="fill_parent "
android:layout_below="@+id/imageView1" >

android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" >

;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" />

I hope You are asking like this

Main Screen
After Scrolling

The Below Code Might Help you,

<?xml version="1.0" encoding="utf-8"?>
<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" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/bg" />

<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" >
<!-- Scroll View can Hold only one "Child"
So Create a Dummy Layout if you
have more than 1 child coming
inside Scroll View -->

<!-- Add any Number of Childs -->

<android.webkit.WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" >
</android.webkit.WebView>

<!-- Add any Number of Childs -->

</ScrollView>

<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" />
</RelativeLayout>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文