Vertical 3dCarousel animation in android?

How can I achieve this animation in android, here is the link below that I tried to change, but there is no way out, as shown below.

enter image description here

http://horribile.blogspot.in/2011/11/android-3d-carousel.html

https://github.com/rameshkec85/Android-VerticalCarousel

I have a function below for vertical animation as shown below.

private void Calculate3DPosition(CarouselItem child, int diameter, float angleOffset) { angleOffset = angleOffset * (float) (Math.PI / 180.0f); float x = 0.0f; float y = (float) (diameter / 2 * Math.sin(angleOffset)) + diameter / 2 - child.getWidth() / 2; float z = diameter / 2 * (1.0f - (float) Math.cos(angleOffset)); child.setItemX(x); child.setItemZ(z); child.setItemY(y); } 

when I implement this as a result, the animation does not work properly, and also the image does not display in the center correctly.

Any body has the correct implementation of this animation, please send me.

Thanks at Advance.

+4
source share
2 answers

I have reached this animation.

Below is a link to the horizontal carousel animation, which is the most popular.

Android 3D animation of a carousel

Now, here are the changes to achieve vertical carousel animation above the animation above.

Carousel.java

  • onFling : change speedX to speedY

  • onScroll: Change trackMotionScroll (/ * -1 * / (int) distanceX); To trackMotionScroll (/ -1 * * / (int) distanceY);

  • scrollIntoSlots: change "if (angle! = 0.0f)" to "if (Math.abs (angle)> 4)"

  • Calculate3DPosition:

    angleOffset = angleOffset * (float) (Math.PI / 180.0f);

      float x = (screenWidth - child.getWidth())/2; float y = (float) (diameter / 2 * Math.sin(angleOffset)) + diameter / 2 - child.getWidth() / 2; float z = diameter*2 * (1.0f - (float) Math.cos(angleOffset)); child.setItemX(x); child.setItemZ(z); child.setItemY(y-(screenHeight - child.getHeight())/2); 

Enjoy the carousel animation.

+6
source

First of all, try installing:

 float x = child.getWidth() / 2; 

This should solve a problem that is not centered. Y and z look fine, but maybe try changing the location of y to allow for the height of the view instead of the width ?:

 float y = (float) (diameter / 2 * Math.sin(angleOffset)) + diameter / 2 - child.getHeight() / 2; 

Not sure if this will work since I didn’t install the project, but I hope that it brings you closer at least :)

Good luck

+2
source

All Articles