如何显示某一部分网页内的web视图通过适合屏幕到所有设备视图、屏幕、适合、部分

2023-09-06 02:31:05 作者:都已转身何必再念

我想告诉好康内部的WebView。截至本是好的。

但我有网页(如下面给出的),我想它的某一部分。我的意思只是左上角应在适合屏幕模式显示在所有设备。

我解决这个问题,因为最后两三天。

我想:我要显示网页的左上角内部web视图显示受不管Stratergy可能与变焦或任何其他选项,但它应该是适合筛选所有设备

一件事的我无法改变网页的源$ C ​​$ C,因为它是固定的。  我得$ C $管理C本身。

我曾尝试:我指#1的联系,但没有运气

下面是我的code。

 的WebView WV;
        WV =(web视图)findViewById(R.id.webview_MyPoops);
        wv.getSettings()setJavaScriptEnabled(真)。

        // wv.setInitialScale(185);

        // wv.setInitialScale(30);
        字符串的URL =MY_LINK;

        wv.loadUrl(URL);

        WebSettings webSettings = wv.getSettings();
        webSettings.setSavePassword(假);
        webSettings.setSaveFor​​mData(假);
        webSettings.setJavaScriptEnabled(真正的);
        webSettings.setSupportZoom(真正的);
        webSettings.setLoadWithOverviewMode(真正的);
        webSettings.setUseWideViewPort(真正的);
 

我收到的设备显示完整的网页。

在我LG的设备(其中有480 * 800分辨率),但在大的设备或标签像银河TAB2,我越来越左上角的非常小的图像和屏幕的所有其他领域工作正常只是背景网页。

下面是银河TAB2的运行上面的code后的截图。 请有你在任何地方,我缺乏的建议。在此先感谢。

解决方案

 的WebView X;

x.setInitialScale(1);
 
我的一部分网页打开后有部分显示一瞬间就消失了

这是furtheset放大的可能。但是,对于一些网站,它只是看起来纯粹的丑陋。

这是我发现的第二个版本

  test1.getSettings()setDefaultZoom(ZoomDensity.FAR)。
 

这就是一个很好的多面手比似乎只是缩小远远不够了很多,但仍然不是我所期待的。

喏,这就是最终的解决方案,我有。

  x.getSettings()setLoadWithOverviewMode(真)。
。x.getSettings()setUseWideViewPort(真正的);
 

基本上,这些做的是回答这样一个问题。

  setLoadWithOverviewMode(真)
 

加载的WebView完全缩小

  setUseWideViewPort(真)
 

I Want to Show WebPage Inside WebView. Up to this it is fine.

But I have WebPage (As Given Below) and I want Certain Part of it. I mean just Top Left Corner should be visible in fit to screen mode in all the devices.

I'm resolving this Problem since last two three days.

What I want : I want to Show Top Left Corner of webpage to show inside Webview by Whatever the Stratergy May be with zoom or any other Option but it Should be fit to screen for all the device.

One More thing I can't change the Source Code of Webpage, because it is fixed. I have to manage by code itself.

What I have Tried : I have refer Stackoverflow links but no luck.

Here is my Code. :

            WebView wv;
        wv = (WebView) findViewById(R.id.webview_MyPoops);
        wv.getSettings().setJavaScriptEnabled(true);

        // wv.setInitialScale(185);

        // wv.setInitialScale(30);
        String URL = "MY_LINK";

        wv.loadUrl(URL);

        WebSettings webSettings = wv.getSettings();
        webSettings.setSavePassword(false);
        webSettings.setSaveFormData(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);

I'm getting complete webpage shown in devices.

It Works fine in My LG Device(Which has Resolution of 480*800) but in big device or tabs like Galaxy Tab2, I'm getting very small image of Top Left Corner and all other Area of screen are just background of WebPage.

Below is the screenshot of Galaxy Tab2 after Running the above code. Please have you Any suggestion where I am lacking. Thanks in Advance.

解决方案

WebView x;

x.setInitialScale(1);

This is the furtheset zoom possible. But for some sites it just looks pure UGLY.

This was the second version I found

test1.getSettings().setDefaultZoom(ZoomDensity.FAR);

Thats a nice all rounder than seems to just zoom out far enough for a lot but still not what I was looking for.

And now here is the final solution I have.

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

Basically what these do is answered in another question like this.

setLoadWithOverviewMode(true) 

Loads the WebView completely zoomed out

setUseWideViewPort(true)