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.
Related
I have an issue for my e-Book app that is I intend to make e-Book page by Webview, but the problem here is paging when its content is too long, I dont want user vertical scroll, uhmm... I mean the content will be cut and hold into a number of Webview base on the height of screen. Can we distibute continuously the content to particular Webview.
Thank for your reading
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
I'm in need of two things:
I need to display a webview that shows the entire webpage (horizontally), and automatically shrinks it to whatever width necessary to display the entire page edge to edge. I'm curious if this
a) can be done at all
b) if so, is this something I can control with JUST the WebView or
c) if I need to modify the HTML of the page to squeeze into whatever the container happens to be.
I have a situation where I need to display Facebook (and Twitter and Pinterest) in WebViews that scale to the size of the device and I want to make sure the WebViews show the entire page rather than creating Horizontal scrollbars.
Then, I'm curious if there's some way I can auto scroll down to a specific coordinate from the WebView so that I can scroll down beneath the massive banners that Twitter and Facebook have at the top and display the users' content without them having to scroll down manually.
Can this be done?
In order to have the WebView shrink the page to the width of the screen, use the following settings in your code.
WebView webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
you can use:
int x = 0, y = THE_NUMBER_YOU_WANT;
view.scrollTo(x,y);
to scroll to any position on the webpage, determining how far you have to scroll down will be challenging though.
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.
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..