2

I am a newbie of Android development. I want to implement a sliding button with animation. The effect is shown in the following video: http://www.youtube.com/watch?v=ImHe4N4mvE4. This is like "slide to unlock" effect of iphone. My question is that how to impelment this kind of effect. Is this app implemented with changeview, scrollview ?

CoolDeep
  • 41
  • 7

1 Answers1

1

you can put an image view with animation in a linear layout whose height is wrap content and width is fill parent

code for animation

    public static Animation inFromLeftAnimation() {
 Animation inFromLeft = 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
 );
 inFromLeft.setDuration(350);
 inFromLeft.setInterpolator(new AccelerateInterpolator());
 return inFromLeft;
 }
public static Animation outToLeftAnimation() {
Animation outtoLeft = new TranslateAnimation(
 Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
 Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
);
outtoLeft.setDuration(350);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
Athul Harikumar
  • 2,501
  • 18
  • 16