2015-12-06 2 views
3

Я читаю фид в своем приложении. Я могу читать все изображения, текст ... и я тоже читаю видео с YouTube. Моя проблема заключается в том, что размер кадра, где я могу посмотреть видео YouTube больше, и я хочу, чтобы этот кадр можно настроить на WebViewКак изменить размер видео youtube в Android-браузере?

Это как выглядит ....

enter image description here

Кто-то знает, как изменить размер кадра видео с YouTube, чтобы настроить его на веб-просмотр?

Заранее спасибо

Это мой 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> 

класс Java, где называть Webview

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

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

ответ

2

I f ound решение. Добавьте это в .html

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

Nice! Я добавил это в .css-файл, который я использую для создания моего содержимого html в WebView –

Смежные вопросы