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 ?
Asked
Active
Viewed 1,586 times
1 Answers
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
-
Thanks but I want to move the slider with finger speed. in This code speed is fixed. – CoolDeep Aug 23 '12 at 09:52
-
change the animation accordingly as per your wish – Athul Harikumar Aug 23 '12 at 09:53
-
or just customise the sliding drawer ( set drawers caller to invisible – Athul Harikumar Aug 23 '12 at 10:00
-
Thank you very much.This is not awesome,But i can implement it temporary.Thanks again. – CoolDeep Aug 23 '12 at 10:12
-
yap just try improving it if you get a better way don't forget to post thanks – Athul Harikumar Aug 23 '12 at 10:15
-
I move handle in sliding drawer and when it reaches more 50% height of the screen it go automatically to the last positions.my question is how to increase this range,so when I my finger reaches to end of the screen it drawer slides in???? – CoolDeep Aug 23 '12 at 11:30
-
you should probably customize the drawer to accomplish that there are a lot of coustamised verssions available – Athul Harikumar Aug 23 '12 at 11:33
-
or you can actually customize the animation given above as per your need – Athul Harikumar Aug 23 '12 at 11:35