我正在阅读应用程序中的提要。我可以阅读所有图像,文本...,我也可以阅读youtube视频。我的问题是可以在其中看到youtube视频的框架的尺寸更大,我希望可以将该框架调整为适合Webview的尺寸

这是看起来。

android - 如何在WebView Android中调整YouTube视频的大小?-LMLPHP

有人知道如何调整youtube视频的帧大小以将其调整为网络 View 吗?

提前致谢

这是我的原始文件夹中的html:

<html>
<head>
    <title>News</title>
    <meta name="viewport" content="initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" />
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <style type="text/css">
        body {
        max-width: 100%;
        margin: 0px 0px; padding:0px;
        text-align: left;
        margin-bottom: 10px;
        }

        #base {
        overflow: hidden;
        width: 87.5%;
        margin:0px auto;
        }

        #header {
        border-bottom: 2px solid #f29a2e;
        line-height: 1;
        }

        #writter {
        border-bottom: 2px solid #f29a2e;
        line-height: 1;
        }

        .title {

        color: #333;
        font-size: 25px;
        }

        .pubDate {
        color: #A1A1A1;
        text-align: left;
        font-size: 14px;
        }

        .redac {
        color: #A1A1A1;
        text-align: left;
        font-size: 14px;
        }

        .image {
        max-width: 87.5%;
        margin-top:10px;
        margin-bottom:10px;
        }

        img, ul, ol {
        display: block;
        max-width:100%;
        margin-top:10px;
        margin-bottom:10px;
        }

        .content {
        text-align:left;
        <!--word-wrap:break-word;-->
        font-size:16px;
        color: #333
        }

        a {
        color: #468CFF;
        text-decoration: none;
        }

    </style>
</head>
<body>
<div id="base">
    <div id="header">
        <div class="title">
            <p>_TITLE_</p>
        </div>
        <table>
            <td>
                <div class="pubDate">
                    <p>_PUBDATE_</p>
                </div>
            </td>
        </table>
    </div>
    <div id="writter">
        <div class="redact">
            <p>_REDACTOR_</p>
        </div>
    </div>
    <div class="content">
        <p>_CONTENT_</p>
    </div>
</div>
</body>
</html>

调用Web View 的Java类
 private void populateWebView() {
        WebView webview = (WebView) findViewById(R.id.articulo_Webview);
        webview.setWebChromeClient(new WebChromeClient());
        webview.getSettings().setLoadWithOverviewMode(false);
        webview.getSettings().setUseWideViewPort(true);
        webview.loadDataWithBaseURL(null, "<!DOCTYPE HTML>"
                + populateHTML(R.raw.htmlnoticia), "text/html", "UTF-8", null);
        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
    }

    private String populateHTML(int resourceID) {
        String html;
        html = readTextFromResource(resourceID);
        html = html.replace("_TITLE_", articulo.getTitulo());
        html = html.replace("_PUBDATE_", "" + articulo.getFecha());
        html = html.replace("_CONTENT_", articulo.getContenido());
        html = html.replace("_REDACTOR_", articulo.getRedactor());
        return html;
    }

    private String readTextFromResource(int resourceID) {
        InputStream raw = getResources().openRawResource(resourceID);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        int i;
        try {
            i = raw.read();
            while (i != -1) {
                stream.write(i);
                i = raw.read();
            }
            raw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stream.toString();
    }

将xml布局到webView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        <WebView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/articulo_Webview">
        </WebView>
</LinearLayout>

最佳答案

我找到了解决方案。将其添加到.html中

iframe {
        display: block;
        max-width:100%;
        margin-top:10px;
        margin-bottom:10px;
        }

10-08 06:35