Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewflipper - Vertical slider

I have did slider using Viewflipper and that is from right to left mean horizontal slider we can say.
But I want to make it top(In from top) to bottom(Out to bottom) mean vertical slider.
Below is my code for horizontal sliding.

public static Animation inFromRightAnimation(int duration) {
        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(duration);
        inFromRight.setInterpolator(new AccelerateInterpolator());
        return inFromRight;
    }

    public static Animation outToLeftAnimation(int duration) {
        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(duration);
        outtoLeft.setInterpolator(new AccelerateInterpolator());
        return outtoLeft;
    }

What change I need to make it vertical(Top to bottom) sliding?

like image 365
Priyank Avatar asked Sep 14 '26 23:09

Priyank


1 Answers

public static Animation inFromUpAnimation(int duration) {
        Animation inFromRight = new TranslateAnimation(
        Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
        Animation.RELATIVE_TO_PARENT,  +1.0f, Animation.RELATIVE_TO_PARENT,   0.0f
        );
        inFromRight.setDuration(duration);
        inFromRight.setInterpolator(new AccelerateInterpolator());
        return inFromRight;
    }

    public static Animation outToDownAnimation(int duration) {
        Animation outtoLeft = new TranslateAnimation(
          Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
          Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f
        );      
        outtoLeft.setDuration(duration);
        outtoLeft.setInterpolator(new AccelerateInterpolator());
        return outtoLeft;
    }

those attributes relate to x and y co-ordinates. i think this will do the job

like image 121
Zombie Avatar answered Sep 18 '26 01:09

Zombie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!