Search code examples
androidanimationandroid-viewpagerandroid-animationnineoldandroids

Animation proxy from nineoldandroid was not working 2.2


friends....

I got a problem with animation in betwen versions...So i will give description about the requirements of my app and problem im facing
1.My consists of animation which consists viewpager.
2.And this animation must work in lower versions such as 2.2.
3.So for this i have found a awsome library ninoldandroid.
4.I have used animation proxy for my animation.
5.It waa working fine in 4.2.
6.But when coming to 2.2 the animation was not working and the viewpager was moving with its default feature.
My code for animation is...

 public class DepthPageTransformer implements ViewPager.PageTransformer {
    private static final float MIN_SCALE = 0.75f;



    public void transformPage(View view, float position) {
        int pageWidth = view.getWidth();
        AnimatorProxy proxy = AnimatorProxy.wrap(view);
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            proxy.setAlpha(0);



        } else if (position <= 0) { // [-1,0]
            // Use the default slide transition when moving to the left page
         proxy.setAlpha(1);

         proxy.setTranslationX(0);

         proxy.setScaleX(1);
         proxy.setScaleY(1);

        } else if (position <= 1) { // (0,1]
            // Fade the page out.
            proxy.setAlpha(1 - position);

            // Counteract the default slide transition
            proxy.setTranslationX(pageWidth * -position);


            // Scale the page down (between MIN_SCALE and 1)
            float scaleFactor = MIN_SCALE
                    + (1 - MIN_SCALE) * (1 - Math.abs(position));

            proxy.setScaleX(scaleFactor);
            proxy.setScaleY(scaleFactor);

        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            proxy.setAlpha(0);

        }
    }
}

Can u tell what i have to implement to make this anim ation work in 2.2. If u feel that the question is insuffient please let me know..Thnaq


Solution

  • There is a Animated view pager by jfeinstein JazzyViewPager which is used by nineoldandroid. which work from 2.2.

    (Sorry for late replay)