简体   繁体   English

Android加载webview内容全屏

[英]Android loading webview content full screen

When I give the following url to webview in android the content is getting displayed top left corner only.当我将以下 url 提供给 android 中的 webview 时,内容仅显示在左上角。 I want to make it full screen(content only).我想让它全屏(仅限内容)。 How can I make it?我怎样才能做到?

http://staging.snagfilms.com/modules/html5player.jsp?filmId=ed9195a0-a748-11e0-a92a-0026bb61d036&w=500&html5=1 http://staging.snagfilms.com/modules/html5player.jsp?filmId=ed9195a0-a748-11e0-a92a-0026bb61d036&w=500&html5=1

Xml: xml:

   <LinearLayout
        android:id="@+id/layout_browser_new1"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:layout_weight="1" >

        <com.verizon.viewdini.ui.custom.CustomFacedWebView
            android:id="@+id/web_wrap_browser"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>

Code:代码:

myWebView.getSettings().setPluginsEnabled(true);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setPluginState(PluginState.ON);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
myWebView.setScrollbarFadingEnabled(false);
myWebView.requestFocusFromTouch();

Use the code:使用代码:

    Webview.getSettings().setBuiltInZoomControls(true);
    this.webview.getSettings().setLoadWithOverviewMode(false);
    this.webview.getSettings().setUseWideViewPort(false);

Use This this lines in xml在 xml 中使用此行

<WebView  
        android:id="@+id/webview_compontent"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1.0"   
    />

enable the following setting lines also.也启用以下设置行。

 WebSettings webSettings = mWebView.getSettings();
        webSettings.setBuiltInZoomControls(true);
        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);
        mWebView.requestFocusFromTouch();

Hope this will help you.希望这会帮助你。

add this to your HTML file:将此添加到您的 HTML 文件中:

<meta name="viewport" content="width=device-width"/>

after that, set this in your code:之后,在您的代码中设置:

WebView.getSettings().setLoadWithOverviewMode(true); WebView.getSettings().setUseWideViewPort(true);

Hope this will work.希望这会奏效。
In case setLoadWithOverviewMode doesn't work as you like, you can calculate the scale ratio between your website'sizee and the webview's size, then apply that scale with如果 setLoadWithOverviewMode 不能按您的意愿工作,您可以计算您的网站大小和 webview 大小之间的比例,然后应用该比例

WebView.setInitialScale(the_scale_ratio);

Remember to remove "viewport" tag in the HTML file in this case.请记住在这种情况下删除 HTML 文件中的“视口”标签。

three steps to make it work.三个步骤使其工作。

  1. make layout full screen with no padding, no margin.使布局全屏,没有填充,没有边距。

  2. make you web page surrounding no padding, no margin.让你的网页周围没有填充,没有边距。

  3. make you web page surrounding no negative left, right, top, bottom floating.使您的网页周围无负左、右、上、下浮动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM