android 滑动动画效果
16lz
2021-01-23
/**
* 定义从右侧进入的动画效果
* @return
*/
protected Animation inFromRightAnimation() {
Animation inFromRight = 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);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
/**
* 定义从左侧进入的动画效果* @return
*/
protected 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(500);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
/**
* 定义从左侧退出的动画效果
* @return
*/
protected 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(500);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
/**
* 定义从左侧进入的动画效果
* @return
*/
protected Animation inFromLeftAnimation2() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.7f,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
inFromLeft.setDuration(500);
inFromLeft.setFillAfter(true);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
/**
* 定义从左侧退出的动画效果
* @return
*/
protected Animation outToLeftAnimation2() {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
outtoLeft.setDuration(500);
outtoLeft.setFillAfter(true);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
更多相关文章
- Android之极光推送发送自定义消息
- Android中一直走马灯效果的TextView
- DialogFragment设置自定义动画
- Android Recyclerview设置条目属性动画
- android折叠展开自定义列表项测试
- Android属性动画(ObjectAnimation)
- 自定义Tab选项卡