android视图寻呼机滑动动画

时间:2015-09-21 07:34:11

标签: android animation android-viewpager swipe android-pagetransformer

我试图通过覆盖transformPage()方法在视图分页器的页面滑动中做一些动画,这样当我从右向左滑动时,新页面(来自右侧的页面)应该出现在前一个下方动画开始后的页面,然后上一页应在新页面的左侧滑动。 当我从左向右滑动时,新页面应直接滑过上一页并完全覆盖它。但我无法实现它。 我尝试过以下方法: -

if(position > 0 && position < 1)
{
    int pageWidth = page.getWidth();
    float translateValue = (-position * pageWidth);
    if(translateValue < pageWidth)
    {
        translationX = translateValue;
    }
    else
    {
        translationX = 0;
    }
}
else 
{
    alpha = 1;
    scale = 1;
    translationX = 0;
}

请提供一些建议。谢谢

1 个答案:

答案 0 :(得分:0)

这应该像你想要的那样工作,你只需要把它放在你的PagerTransformer类中:

addTodo()
相关问题