What Android Api is used to get the scrolling to the left or to the right on the start screen on Android?
You are looking for GestureLibraries class. Read more about it here.
I haven't used this myself so I can't give you more info, but these might also be useful:
It's all in the source repository for you to browse:
In the later versions it's using ViewGroup.onInterceptTouchEvent and View.onTouchEvent to catch the drag, and doing the calculation manually based on the amount of movement from when the touch started.
The actual movement is just done via View.scrollBy.
Check this example: http://www.zumodrive.com/files?key=5SBbYzk0Mj#item=170533463
The simplest way is by detecting a "Fling" gesture. The android API has a built in detector for basic gestures like flinging, scrolling, long press, double tap, pinch zoom, etc.
The documentation is available at http://developer.android.com/reference/android/view/GestureDetector.html.
What you do is create an instance of GestureDetector, override the onTouchEvent method of the view you are interested in detecting gestures for, and pass the MotionEvent to the GestureDetector.
You also have to supply a OnGestureListener implementation (easiest to extend SimpleOnGestureListener) to the GestureDetector and that will handle all of your gesture events.
Example:
class MyView extends View
{
GestureDetector mGestureDetect;
public MyView(Context context)
{
super(context);
mGestureDetect = new GestureDetector(new SimpleOnGestureListener()
{
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
//check if the fling was in the direction you were interested in
if(e1.getX() - e2.getX() > 0)
{
//Do something here
}
//fast enough?
if(velocityX > 50)
{
//etc etc
}
return true;
}
}
}
public boolean onTouchEvent(MotionEvent ev)
{
mGestureDetector.onTocuhEvent(ev);
return true;
}
}