【问题标题】:Video is not rendering in full screen in webview once changing the device mode from portrait to landscape将设备模式从纵向更改为横向后,视频不会在 webview 中全屏呈现
【发布时间】:2018-11-30 18:28:24
【问题描述】:

我正在 android webview 中播放来自 youtube 的视频。一旦我将设备模式从纵向更改为横向,它就不会全屏显示,即使我在运行时根据设备模式设置视频视图的高度和宽度。

我的代码是:

WebView mWebView = new WebView(this);

    WebView mWebView = (WebView) findViewById(R.id.test_webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.getSettings().setPluginState(PluginState.ON_DEMAND);
    mWebView.getSettings().setUseWideViewPort(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);


    String summary = "<html><body style='background-color: rgb(38,38,38);'><video controls='' autoplay='' style='margin: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 0;' name='media' src=http://www.youtube.com/watch?v=bqd491U4XEs></video></body></html>";

        mWebView.loadData(summary, "text/html", null);
}

【问题讨论】:

  • 欢迎来到 SO。您应该向我们展示您的代码,以便我们为您提供帮助

标签: android


【解决方案1】:

设置xml文件中WebView的高宽为

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    相关资源
    最近更新 更多