Android滑块按钮小部件

时间:2012-08-23 09:10:45

标签: android slider translation

我是Android开发的新手。我想实现一个带动画的滑动按钮。效果显示在以下视频中:http://www.youtube.com/watch?v=ImHe4N4mvE4。这就像iphone的“滑动解锁”效果。我的问题是如何促使这种效果。这个应用程序是用changeview,scrollview实现的吗?

1 个答案:

答案 0 :(得分:1)

您可以将带动画的图像视图放在线性布局中,其高度为换行内容,宽度为填充父级

动画代码

    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;
}
相关问题