Probably the easiest way is a ViewFlipper w/left & right transition
animations:

1) extend a ViewFlipper
2) make 4 TranslateAnimations (inFromLeft, outToLeft, inFromRight,
outToRight, adjust the constructors as necessary)...

private final TranslateAnimation mInFromLeft =
        new TranslateAnimation(Animation.RELATIVE_TO_PARENT,-1.0f,
                Animation.RELATIVE_TO_PARENT,0.0f,
                Animation.RELATIVE_TO_PARENT,0.0f,
                Animation.RELATIVE_TO_PARENT,0.0f
        );

3) add a GestureDetector to catch flings.  In the OnGestureListener
method, set the appropriate animations for the ViewFlipper's
setInAnimation() and setOutAnimation() methods, then call the
ViewFlipper's showPrevious()/showNext() methods based on the direction
of the fling (or movement)

4) if you want "book-ends" like the home screen, check for the
displayed child index before you call showPrevious()/showNext() in the
OnGestureListener method body.  Otherwise, you can just blindly call
showPrevious()/showNext() for a "carousel" effect, the ViewFlipper
will automatically "wrap" back to the first index when it reaches the
end.

Or, dig into the "Home" source which is included w/the SDK (platforms
\android-1.5\samples\Home\src\com\example\android\home)


On Jul 9, 9:36 am, 单单 <[email protected]> wrote:
> For example, I have an application containing 3 interfaces(each one
> occupys a screen), I want to switch different interfaces by touching
> on the screen. Just like the desktop has 3 parts, we can move from one
> to anohter by touching.
>
> Can anyone tell me how to implement the kind of effect or where is the
> code of Android desktop slide effect.
>
> Any help will be highly appriciated!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to