Implementing horizontal/vertical finger swipe scrolling in android honeycomb webview/webkit? - android

I am planning to implement Honeycomb tablet application based on WebView (so, basically it'll be a HTML5 web based application made only for tablet).
I am looking to implement horizontal and vertical scrolling by swiping finger. For better understanding I created sample outline.
This image shows something similar to Honeycomb's native setting activity with left and right page vertically scrollable
Any kind of guides or resources are welcome. Thanks

Take a look at iScroll:
iScroll 4 is a complete rewrite of the original iScroll code. The script development began because mobile webkit (on iPhone, iPad, Android) does not provide a native way to scroll content inside a fixed width/height element. This unfortunate situation prevents any web-app to have a position:absolute header and/or footer and a scrolling central area for contents.
While latest Android revisions are supporting this functionality (although support is not optimal), Apple seems reluctant to add one finger scrolling to divs...

Here is what I have found so far:
It depends on how you want to implement scrolling. If you want to attached swiping event, thats the easiest way to implement using well known libraries:
jqTouch - It has swipe left and right event which can be hooked to scroll left or right (it seems all the webkit based animations work only on iOS devices). Please note that project is still in beta and not highly active. EDIT: this is also part of Sencha Labs - who actively maintains Sencha Touch.
Sencha Touch - They have better support for almost everything in mobile and tablet. (Note: It's free for opensource apps but not for commercial apps - EDIT: they actually have commercial license. see their site for more info on licensing)
jQueryMobile - They are very stable (in RC1 as of now), and has swipe left and right event, but I could not find swipe up or down. If you just need swipe left right, tap, tap hold, then go with jQM. They have the best community support.
RAW JS - Finally, if you want something raw javascript, visit HTML5Rocks article to have better in-depth idea about how touch event works.
I hope it helps. I'm still struggling to implement scroll up down, since I don't want to wait for swipe to end, instead I am trying to implement instant scroll feedback, getting very close using RAW JS coordinates, but not satisfactory.

Hammer JS has been useful for me:
http://eightmedia.github.io/hammer.js/

From the creators of iScroll, SwipeView seems a nice dedicated alternative. Have a look at demo 1 and demo 2.
I have not tested yet, but I will surely. Since demos behave well on my iPad.

You might find this library quite useful: https://github.com/cubiq/2-way-iScroll
It handles the case of vertical scroll and horizontal swipe.

Related

Phonegap vertical scrolling within page issues

I'm building a phonegap(cordova) application and it is working great for android, but there is some scrolling issue with iOS build i-e i cannot scroll pages from anywhere on the screen except the middle-right and middle-left of the screen and that area is very less, i want to scroll by swiping anywhere on the screen just like it works in Android.
Anyone else faces the same issue, share your knowledge and experience.
Although without a code sample it is difficult to advice.. I had similar experiences in ios phonegap development and you need to be sure that the css overflow attribute is correctly setup for all elements.
One major 'trick' that you need is to add
-webkit-overflow-scrolling: touch;
To the container you like to scroll.
See this page for info about the css property.

Titanium Mobile: Slide to switch between the views

I am developing a mobile app using Titanium. I came across the Google Plus, Tweetdeck, Market Apps for Android. To switch between the tabs they use the slide gesture. Its like the next view simply slides in based on your swipe/drag. I would also like to add the same kind to behavior for my app I would like to have it work on both Android and iOS platforms. How can I have it?
I have tried Ti.UI.scrollableView. The problems I faced were
The sliding was not as responsive as seen in the above apps.
The view does not move along with the finger drag. It moves after the finger drag is finished.
It seems to take more memory as the application response slows drastically and animations dont appear to be smooth.
Kindly let me know if there is any other alternative to implement this kind of experience in the app.
Thanks!!
What you basically need is a Ti.UI.ScrollableView which implements the native Android ViewPager. Those other Apps are binding their Tabs to the ViewPager. You can't do this with a Ti.UI.TabGroup but you can either use your own Tab views or some other module that provides this functionality like this. You could also have a look at my Alloy widget here - it provides a custom tab-indicator for Ti.UI.ScrollableView (without another module).
For Android you should consider using a third-party library to implement such functionality.
Personally I use PagerSlidingTabStrip which I have found that works really well.

Android Sliding Transition

I apologize if the question is of the newbie level but I just started learning android to create mobile magazine apps for my company and what I would like to achieve is an effect similar to the native iPhone's / iPad's scroller in the home page (one where the apps that are currently installed are displayed).
Page transitions will be made in accordance with the user's gestures. Thank you for the help!
I think
'Page transitions will be made in accordance with the user's gestures'
means not ViewFlipper's behavior.
I recommend to use ViewPager, which is available in android-support-v4 library.
search for android-support-v4 library and documents.
I'm open for any regarding questions.
This can be achieved with ViewFlipper and gesture Detection.
View Flipper will help you flip between multiple views and gesture will help you to swipe between views to achieve it. Here are few links which will get you started.
How to make an Android view that flips between views on swipe/fling
http://www.mediafire.com/?fg32sn1345xn5dl
http://android-journey.blogspot.com/2009/12/android-viewflipper-and-slidingdrawer.html

Implementing a HomeScreen-like horizontally scrollable widget?

Most Android devices feature a home screen which you can scroll horizontally by dragging (there're others that have a grid-like 2d scrolling feature too, but I'm only interested in horizontal scrolling).
Could someone shed some light for me on how this might be achieved?
First I was thinking about using a custom ViewFlipper. I could attach proper sliding animations for it, but it's not exactly the same thing. On the home screen, the "amount of sliding" depends on how far you've dragged your finger on the screen. Animations are fire-and-forget things, I can't stop them midway.
Any ideas?
Here's a video about the desired behaviour: http://www.youtube.com/watch?v=UGdWM2TQNSo&feature=player_detailpage#t=104s
You can take a look at the way Android's stock Launcher app does this here: https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Workspace.java
You're primarily interested in the onTouchEvent, onInterceptTouchEvent, and computeScroll methods.
Google released the compatibility pack with some new UI Elements, which you can download via SDK Manager.
put the .jar file located in sdkfolder/extras/compatibility in your build path.
now you can use a class called ViewPager which behaves like the Android Homescreen.
Or, if you are using Eclipse and ADT plugin v12 or higher, just right click your project, choose "Android Tools" and then "add compatibility package".

What's the android design pattern for multiple pages?

I'm working on an android app that has a section that feels like an iPhone home screen. There's a bunch of pages that are essentially displaying the same data in different configurations and users should be able to quickly move between them. Generally there won't be more than 4 or 5 pages.
I could just replicate the experience with the iPhone home screen with multiple dots on the bottom of the page, but that doesn't feel very android-friendly. What's the design pattern in android for viewing and interacting with this type of view? I know the android home screen has a variant with dots, but I've never seen it used within an app.
Screenshots or links to existing apps would be great.
The stock Android launcher has left/right paging behavior on the home screen, and it's open source.
This is the Workspace class. Pay special attention to the onTouchEvent and onInterceptTouchEvent methods. The utility classes Scroller and VelocityTracker are used together to define the behavior for snapping to a page when the user lets go from a drag.
https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Workspace.java
Hootsuite uses this design pattern and it works well in my opinion. I don't think it affects the user experience on Android in a negative way. I find that the biggest problem with people porting iPhone applications to Android is the fact that they try to port every single design pattern over. I don't think what you're trying to implement will be an issue.

Categories

Resources