-1

In my webview app i am trying to load a webpage and i made some changes by removing some items from the webpage using javascript. Now the remaining part is mainly in the right side of the webpage.so please help me to load the webpage focused in the right side.i got a function scrollTo() from some tutorial.but i dont get the idea to use that

MyWebViewActivity.java

package com.example.admin;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Picture;
import android.graphics.Point;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;
import android.webkit.WebView.PictureListener;
import android.webkit.WebViewClient;

@SuppressWarnings("deprecation")
public class MyWebViewActivity extends Activity {

 private WebView webView;

@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView)findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setBuiltInZoomControls(true);
        //webView.getSettings().setDefaultZoom(ZoomDensity.FAR);
        webView.setInitialScale(65);
        Point Scroll=new Point(0,0);
        Scroll.x=webView.getScrollX();
        Scroll.y=webView.getScrollY();
        webView.scrollTo(Scroll.x,Scroll.y);
        webView.loadUrl("http://app.samworkshops.org/User_Reg.aspx");
        webView.setWebViewClient(new WebViewClient() {


            @Override
            public void onPageFinished(WebView view, String url) {
                StringBuilder builder = new StringBuilder("");

                builder.append("javascript:document.getElementById('Image3').style.visibility= 'hidden';");
                builder.append("javascript:document.getElementById('Image3').style.display   = 'none'  ;");
                builder.append("javascript:document.getElementById('Image4').style.visibility= 'hidden';");
                builder.append("javascript:document.getElementById('Image4').style.display   = 'none'  ;");
                builder.append("javascript:document.getElementById('Image5').style.visibility= 'hidden';");
                builder.append("javascript:document.getElementById('Image5').style.display   = 'none'  ;");
                builder.append("javascript:document.getElementById('LnkVolunteer').style.visibility= 'hidden';");
                builder.append("javascript:document.getElementById('LnkVolunteer').style.display   = 'none'  ;");

                view.loadUrl(builder.toString());

            }

        });
    }

}
sadab
  • 59
  • 2
  • 7

1 Answers1

0

I think this should be something like:

Point Scroll=new Point(0,0);
Scroll.x=150; // The new offset here.
Scroll.y=webView.getScrollY();
webView.scrollTo(Scroll.x,Scroll.y);

You can use this post: Android Webview - Webpage should fit the device screen to get the window width. And than scroll all the way to the right.

Community
  • 1
  • 1
Niels
  • 48,601
  • 4
  • 62
  • 81