2

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

4

1 回答 1

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;
}
于 2012-08-23T09:19:07.153 回答