在web视图启用水平滚动视图、水平、web

2023-09-06 13:59:35 作者:沵好、呐年旧时光

在我的WebView活动,我可以垂直滚动网页(上下),但我不能水平滚动它(从右到左或从左至右),当我缩放网页太,但仍然没有水平滚动。

是否有可能加入这个在web视图? 非常感谢你。

  getWindow()setFeatureInt(Window.FEATURE_PROGRESS,Window.PROGRESS_VISIBILITY_ON)。

        mWebView =(web视图)findViewById(R.id.webview);

        。mWebView.getSettings()setBuiltInZoomControls(真正的);
        。mWebView.getSettings()setSupportZoom(真正的);
        mWebView.setVerticalScrollBarEnabled(真正的);



        mWebView.setWebChromeClient(新WebChromeClient(){
            公共无效onProgressChanged(web视图来看,INT进度)
            {
             //使加载URL后杠消失,并改变字符串载入中...
            MyActivity.setTitle(载入中...);
             MyActivity.setProgress(进度* 100); //使酒吧后消失网址是装

             完成加载后//返回应用程序名称
                如果(进度== 100)
                   MyActivity.setTitle(R.string.app_name);
              }
            });
        mWebView.setWebViewClient(新操作());
        mWebView.getSettings()setJavaScriptEnabled(真)。

        mWebView.loadUrl(myURL);
 

XML:

 < XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
  的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:方向=垂直
  机器人:layout_width =FILL_PARENT
  机器人:layout_height =FILL_PARENT
>
  <的WebView
    机器人:ID =@ + ID / web视图
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
  />
< / LinearLayout中>
 
IOS编程教程 十二 创建标签栏和网页视图

解决方案

简短的回答:

使用这种

  mWebView.getSettings()setUseWideViewPort(真)。
 

的回答:

有可能是由于以下的任何因素

setLoadWithOverviewMode(真)加载的WebView完全缩小

setUseWideViewPort(真)使web视图有一个正常的视区(如一个正常的桌面浏览器),而当假的WebView将有一个视受限于它自己的尺寸(所以如果web视图是50像素* 50像素的视口将是相同的大小)

  Webview.setInitialScale(XX);
 

In my webview activity, I can scroll the webpage vertically (up and down) but i can't scroll it horizontally (from right to left or from left to right), when I zoom the webpage too, there is still no horizontal scrolling.

Is there any possibility to add this in the webview? Thank you very much.

getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

        mWebView = (WebView) findViewById(R.id.webview);

        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.setVerticalScrollBarEnabled(true);



        mWebView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)   
            {
             //Make the bar disappear after URL is loaded, and changes string to Loading...
            MyActivity.setTitle("Loading...");
             MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded

             // Return the app name after finish loading
                if(progress == 100)
                   MyActivity.setTitle(R.string.app_name);
              }
            });
        mWebView.setWebViewClient(new Manipulation());
        mWebView.getSettings().setJavaScriptEnabled(true);

        mWebView.loadUrl(myURL);

XML:

<?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:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />
</LinearLayout>

解决方案

Short answer:

Use this

mWebView.getSettings().setUseWideViewPort(true);

Long Answer:

It might be due to any of the below factors

setLoadWithOverviewMode(true) loads the WebView completely zoomed out

setUseWideViewPort(true) makes the Webview have a normal viewport (such as a normal desktop browser), while when false the webview will have a viewport constrained to it's own dimensions (so if the webview is 50px*50px the viewport will be the same size)

OR

Webview.setInitialScale(xx);