Can you set page location (x,y coords) in webview?

Put your problem here if it does not fit any of the other categories.

Can you set page location (x,y coords) in webview?

Postby harryc8786 » Wed Nov 25, 2009 7:27 pm

Hell all,

I'm new here but I did searching on this site and had done a lot on Google. My problem is that I have a WebView I'm using to load a small web page. However to make the users experience a bit more pleasant, I wanted to have my WebView load at a specific location of the website. I tried looking at things Eclipse would suggest but the best I got was setting coordinates that didn't jump to the location on the page but offset the scroll bars. The only minor improvement I made was setting the perspective to 75% of original size for a better fit.

Here's part of my code.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. WebView wv= (WebView) findViewById(R.id.wv);
  2.  
  3.                 wv.loadUrl("http://example.com");
  4.  
  5.                 wv.setInitialScale(75);
  6.  
  7.                 wv.setPadding(50, 15, 0, 0);//thought this would work
  8.  
  9.                          //but offsets the scrollbar
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


If you understand my question and know how to perform this, please let me know.

Thanks!
harryc8786
Freshman
Freshman
 
Posts: 2
Joined: Wed Nov 25, 2009 7:10 pm

Top

Postby Kur1310 » Thu Nov 26, 2009 10:10 am

hey u can use webview's ScrollTo(int x,int y) method to do this....
when the page loading is over u can use this method....
For that u have set a webViewClient to the webview and in that, u have to call the ScrollTo() mehtod in onPageFinished() event..
Just refer the following code snippet:::.....


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. webview.setWebViewClient(new WebViewClient() {  
  5.  
  6.                 @Override  
  7.  
  8.                 public void onPageFinished(WebView view, String url)  {    
  9.  
  10.                                 webview.scrollTo(x,y);
  11.  
  12.                 }  
  13.  
  14. });
  15.  
  16.  
  17.  
  18.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
-Kur
Kur1310
Junior Developer
Junior Developer
 
Posts: 20
Joined: Wed Oct 28, 2009 10:50 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests