Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my page slide as the user slides finger on the screen?

Tags:

android

slider

How can I make my page slide as the user slides finger on the screen? Any example code?

I just require the same feel as it is on my android g-phone's home screen. The screen moves as the finger moves (also includes the elastic effect).

like image 582
Muhammad Maqsoodur Rehman Avatar asked Apr 23 '10 10:04

Muhammad Maqsoodur Rehman


4 Answers

Check out this tutorial and its follow up on warriorpoint. They explain how to use the ViewFlipper to smoothly animate the transition from one screen to another, and then in the second part how to do this using touch control. Note, these are whole-screen transitions not panning around on an existing page. For panning, e.g. on an oversized image that doesn't fit in the screen, check out Android BigImage. Depending on what you're trying to do these might be overkill, but it's not 100% clear what you're trying to achieve.

like image 79
Steve Haley Avatar answered Nov 13 '22 12:11

Steve Haley


Use SwipeView class

http://jasonfry.co.uk/?id=23

https://github.com/fry15/uk.co.jasonfry.android.tools

like image 34
ludwigm Avatar answered Nov 13 '22 12:11

ludwigm


ViewPager. This would seem to have been addressed more completely after the fact:

Whether you have just started out in Android app development or are a veteran of the craft, it probably won’t be too long before you’ll need to implement horizontally scrolling sets of views. Many existing Android apps already use this UI pattern, such as the new Android Market, Google Docs and Google+. ViewPager standardizes the implementation.

like image 9
Bob Avatar answered Nov 13 '22 12:11

Bob


The Home screen is made of two layers:

  • The background (or Workspace) that shows the image; this layer scrolls and draws the wallpaper with a different scroll value. Workspace behaves more or less like a simplified horizontal layout

  • The screens (or CellLayouts) that display the icons; this layer is made of 3 CellLayout side by side. CellLayout is a custom grid-like layout.

The fling is implemented using a VelocityTracker, a Scroller and regular View.scroll methods.

like image 2
Diego Palomar Avatar answered Nov 13 '22 12:11

Diego Palomar