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