Android WebView: How do I horizontally scroll between different pages? - android

I have several HTML pages that I'd like to be able to scroll horizontally, kind of like how you would read a book or a magazine. But instead of a totally smooth scrolling horizontally, I would like each page to kind of click into place as I scroll.
What is the best way I can go about doing this?

Maybe use a ViewFlipper with multipe WebViews and add animations when you flipp through your views.
Also you would have to add a GestureDetector and implement the onFling() method.
Depending on how many webpages you have you might want to limit the amount of WebView instances and resuse them and just load another page when they are shown.

Related

Xamarin Forms / Android ScrollView with Paging, same as UIScrollView.PagingEnabled

I want to create a scroll view with pages that can be scrolled vertically and horizontally as well.
The scroller should be just like a slideshow on a website, to slide between images (content). Something like ScrollView, but to stop at a certain point when scrolled.
I am using this in Xamarin.Forms, so I'll need to create a custom renderer (Android) and set the content of the pages from Forms.
I tried ViewPagers, but I want to be able to set the content from Forms page, not from predefined layouts...
I just couldn't find a clear example/tutorial so I can understand how to approach this problem. I also think about overriding some methods from ScrollViewRenderer class, to intercept and only slide to a certain point, but have no idea which methods and properties to change.
Something like CarouselPage on XF, which can be used inside a layout.
Any help or examples would really be appreciated. Thanks!
I'm searching for 2 days for a solution for this problem.

Scrollable and zoomable view with webviews

Let me start by saying - I know there are quite a lot of posts on this issue. I've been digging and testing it quite a bit, but couldn't come up with the proper solution to my specific requirements.
I need to have a master view with several webviews inside it, and more than one should be visible at a single moment. For this master view - I need to be able to scroll it (to reveal invisible webviews) and to zoom (in order to focus on a single webview).
I've tried TableLayout, but had problems with the zoom (and painting issues with the scrolling). I've tried scroll views, but also read it's not recommended.
Any ideas or recommendation regarding how to achieve this?
Thanks,
yakobom
A simple approach could be to have only one webview with the root html doc containing multiple iframes. Load each page in one of the iframes.
This way the scrolling/zooming could be handled by the webview itself.
Scrollable view can be achieved by adding a scroll view in .xml file and placing remaining text views, edit texts in that scroll view..
to scrolling webview:
mWebView2.getSettings().setJavaScriptEnabled(true);
mWebView2.getSettings().setLoadWithOverviewMode(true);
mWebView2.getSettings().setUseWideViewPort(true);
mWebView2.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView2.setScrollbarFadingEnabled(true);
to zooming webview:
webView.setInitialScale(50);
webPlanSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
webPlanSettings.setUseWideViewPort(true);

multiple screens to scroll horizontally, but not vertically

I am trying to achieve multiple scrollable views on one activity.
I am using viewpager, in each screen there will be multiple buttons using baseadapter, where clicking on one will start certain level, similar to what you see in many of the current games.
I managed to do this and it is all good, one thing I couldn't do is to stop the page/buttons from scrolling vertically, even when all buttons are already on display, you still can scroll them up and down :(
when you scroll horizontally, it goes to the next/previous page, that is good, but how to disable scrolling vertically?
I am considering doing the hole thing in canvas, and make it from scratch, I just don't want to do it the hard way and want to learn the easy way of doing it, if there is any.

Horizontal Scrollview with pages in Android

I am looking for a behavior very similar to ios where we can scroll horizontally to see multiple pages (like a walkthrough/demo). In ios we can do it with UIScrollView and PageControl but not sure how can that be done in Android?
I don't mind if it's not possible to add the bullets of PageControl. I am more concerned about the pages type behavior of scrollview.
Take a look at this article on viewPager, I think it has the something as you require.
http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html
You can use ViewFlipper in android to scroll or swipe between the different layouts....
Try searching "android ViewFlipper onFling()" on google..
http://www.codeshogun.com/blog/tag/view-flipper/

Android -- Displaying HorizontalScrollView of WebViews

So, the idea is to be able to view a very simple html page (text and one image) that can scroll vertically and place this view in a horizontal list that scrolls and snaps to the closest html page.
I've read over and over that, for performance reasons, it isn't a good idea to place web/scroll views inside list views. I'm trying to avoid writing a new view from scratch but am lost as to what direction I should go.
To get the snapping to occur, you may want to consider using a Gallery. It essentially works the same as the list view but is horizontal.
To avoid using a webview, consider using the Html.fromSource function. See this post for details.

Categories

Resources