How i can achieve this animation in android, here below is the link which i have tried to modify it but there is no output like below image.
http://horribile.blogspot.in/2011/11/android-3d-carousel.html
https://github.com/rameshkec85/Android-VerticalCarousel
i have modify below function for vertical animation as 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, animation is not work properly and also image is not display in center correctly.
does any body have implement this animation correctly, Please send me.
Thanks in Advance.
i have achieved this animation.
Below is the link for horizontal carousel animation which is most popular.
Androd 3d carousel animation
Now, here is the changes to achieve vertical carousel animation from above animation.
Carousel.java
onFling : Change velocityX To velocityY
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 carousel animation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With