Webview zoom functionality not stable after refresh activity - android

In my activity all content are manage in webview with all web settings.
and my activity content is refresh every 1 second. So when I am trying to
zoom webview. every second webview maintaing its original position.
I want to maintain zoom state in webview. and this happens only in
version 4.0.3.
my webview is in Timer function . and all settings of webview are below .which
outside of Timer function :
web.getSettings().setBuiltInZoomControls(true);
web.getSettings().setSupportZoom(true);
Please help me. If anyone knows.

Maybe if you use these function:
https://developer.android.com/reference/android/webkit/WebSettings.html#getDefaultZoom()
https://developer.android.com/reference/android/webkit/WebSettings.html#setDefaultZoom(android.webkit.WebSettings.ZoomDensity)
You'll be able to read the zoom level before refreshing, and set it again after the refresh if finished?

Related

Android: get screenshot from hidden WebView every new page redraw

New to Android programming. I need to develop an app getting screenshot of a webpage every time something change inside it. My first way was to extend WebView class and overrite onDraw() call. This allow me to know when web page change by get redraw request and take new screenshot. The problem is, obviously, onDraw is called only if the WebView control is currently visibile on the view but in my case I need to keep it hidden since I want to use only the webkit engine in background and show in the interface only the screenshot of the current page. If I keep hide the WebView no redraw event is delivered. So my question is if there is a way to make what I need? (hope to explained well my problem). Please note, "keep hide" mean I don't put the WebView control inside the layout interface but create separately by using something like "new WebView(this)" at app startup.
Thank you
Just render to a bitmap as these guys did: Converting a view to Bitmap without displaying it in Android?
Override onPageFinished and draw the view in there.

Stop WebView rendering until the page is fully-loaded

I'm working on an app that is using WebView. Unfortunately, when user clicks a link, when the page is loading, the whole WebView area "blinks" until its loading is complete. There's also 1 more problem with it - I'm using a JavaScript that reverses colors of the page at the end of its loading - so until it's fully-loaded, the colors are normal, so again - blinking.
So, what I wannna do is "stop" rendering of the WebView, until the page is completely loaded - then, resume the rendering, so it won't blink. How to do that?
Note: I don't want to modify the webpage to achieve what I want. I have to modify WebView behavior.
And one more note, because it's maybe not clear: by "stop rendering" I mean "display currently rendered page continually until the new one is fully loaded" :)
First make your layout background color white then make the WebView invisible.
after this use AsyncTask then put your webview loading in doInBackground and when it's finished in onPostExecute make your webview visible.
so the user will see the white layout first then the visible webview after fully loaded in postexcute
sorry if my english not good
You could implement a custom WebView, and override it's invalidate() method to do nothing until the page is fully loaded.

Occur some event when click on Webview

I am using webview in my application which opens html website. Now as per requirement of my company, I need to occure some event when user click on webview.
I have tried setOnClickListener() event but it dint work.
Please guide me for it. Thank you.
create a framelayout and then set webview inside on it, put your onlclick listener on the framelayout

zoom in/out (+/-) in webview android

In my application I have one Webview and two buttons next and previous. First time load content from database after that I zoom my Webview and change the page using next button then display content but the zooming is stated.
So my question is that how I change a Webview in initial scale?
I used this:
web1.getSettings().setBuiltInZoomControls(true);
and after click on next page used this:
web1.getSettings().setDefaultZoom(ZoomDensity.FAR);
web1.setInitialScale(100);
but no any effects.
Please help me.
Try using web1.getSettings().setLoadWithOverviewMode(true); and web1.getSettings().setUseWideViewPort(true);

Android webView Load in Background

I have an app which i want to open a webview
right now i am loading the webview the most simple way
i would like to load the webpage in the background so the user will not have a waiting time
maybe in a service running in the background or in a prevoius activity
i looked around the forums and could not find a refrence to the subject
help will be appriciated.
Thx
You can set the webview's visibility to GONE and load the page and when onPageFinished is fired, you can then show the webview.
Hope this helps.
I hade the same problem a while ago, I know what you want. Asynctask! here is a good link I read on to get it to work!
http://www.brighthub.com/mobile/google-android/articles/82805.aspx
How you get it to work properly.
Load your webview in the doInBackground and perhaps a ProgressDialog that shows that your app i working?
GL mate
you can use asynctaskLoader take a look it's better than the asynctask because it can manage the orientation changed and some other cool things...

Categories

Resources