I have a webview, in which I load images.
When I zoom in, I want users to scroll to view the rest of the contents. But when I scroll horizontally, horizontal flip is getting triggered.
Is there anyway to stop this?
This blog is very usefull in the matter: Preserving screen state in WebView. It works even for JavaScript variables etc..
Related
In Netflix's Android app, there is a WebView that covers almost the entire app's area. When you drag a row left to right, it will scroll only that row, and do so using nice inertial scrolling. If you drag up and down, it will scroll the whole page up and down.
I've managed to duplicate this functionality on iOS (in a uiWebView as well as in Safari proper), but not on Android. On Android devices, anything I do is either painfully slow to scroll, or you have to be very careful scrolling vertically to start by touching in the background area between rows. Neither of which are acceptable. Obviously, I don't want to do the scrolling animation in javascript, as that will be too slow.
I know Netflix does it using a WebView, so....what is the trick they are using?
I have tried using the css properties (for the row div):
overflow-y: hidden;
-webkit-overflow-scrolling-x: touch
to no avail.
If you can't get the css Android compatible for your particular WebView, why not create server-side functionality that outputs only requested rows into seperate WebViews?
I would do the following:
* Query the web server to determine how many rows there are.
* Programmatically add the amount of rows that the web server says it has. For example, if the server reports that there are 5 rows, create 5 WebViews, each with their own URL params (ex: the first WebView would query mydomain.com/wv?row=1).
* Put each WebView row in a HorizontalScrollView, and put all HorizontalScrollViews in a VerticalScrollView.
* On URL change, go to a full-page WebView that displays the details of the clicked tile.
* On back pressed, close full page WebView and reload rows.
Not the cleanest of solutions, but should work fine.
Try to use iScroll in your HTML.
In the link you can find the source code, examples and javascript libs.
Also it has some useful callbacks.
I use it a lot when I'm working with WebViews.
Netflix could have used custom gesture detection and have seen if the scroll was more horizontal then vertical or more vertical than horizontal, and then based on how far the scroll was, scrolled the webview horizontally or vertically
Is it possible to scroll out of the page bounds in a webview?
Example: Webview page/content width: 15px, screen size: 10px. Can I scroll to X position 8px?
Technically I can, and it worked fine on my test device. However, testing on other devices I notice that it will stop rendering when I move out of the bound. The left part of the page will be 'blurry' or not visible at all, till I scroll back left and there is no more "empty space" in the webview, than it will update.
Is there a solution for this?
A possible solution would be making the content larger on the fly, with white space. But I cannot add padding to the webview, unless I put it in the html BEFORE I render it. But before I render it I won't know the width. After I render it there is no way to change the padding/add some empty space to the content, without loading it completely again. Right?
I solved this by added 1-2 page-breaks at the end of the html, it will render fine now and I customly prefent the view from scrolling to the end of the page, so that the white is not shown to the user.
Has anyone been able to create of find an open source way to implement a horizontally scrolling Grid view? For phones a vertical scroll makes sense as apps are usually used in portrait mode, but on tablets when in landscape a left to right scroll seems much more usable then a top to bottom scroll.
I ended up going with a page swipe motion to swipe left and right one page at a time as demoed by Google in the Google IO 2011 app
hi how to set scroll length to web view in android?
i wanted to scroll web screen for fixed length. I'm displaying a web page in web view and i adjusted web content using div tag to scroll horizontally. till here no problem and i want to add feature to webview that once user tap the screen horizontally it should move up to fixed length to the right.
Do you know how to do it with JavaScript? When handle a tap on Android side, and then use
WebView.loadUrl("javascript:....")
to adjust scroll offset of browser window.
I know this question has been asked before, but I couldn't get an answer for my issue. I have a large image, and I would like to display it with it's full sizes (in fact its a custom map image). I know that the image can be scrolled by swiping the finger, but my question is if there is a way to implement a vertical / horizontal scrollview for this. I would like to be able to use the scrollview features (swiping the finger an the image is scrolling by itself).
Using a HorizontalScrollView inside a ScrollView didn't work either. The horizontal scroll bar appears only sometimes, and there is no way you can scroll in both directions.
Any help is appreciated.
Thanls a lot,
Gratzi
I've just answerd that question here Images in ScrollView in android
However it does not do scrolling by itself, that would need more programming.