How to create list with carousel effect in android

2019-07-08 03:16发布

问题:

I've gone through with many solutions but still looking for best. I want to do something like

This should be a list containing custom cells and it shall be showing one view highlighted at one time and two adjacent views(pre/post) must be shown slightly.

If anybody have any experience in this work please share. Any help would be highly appreciated.

回答1:

Are you open to html5/hybrid solutions ? There are many libraries in the market that does the work for you. In case you need some on android platform, you have to explore the animation framework and create a custom all by yourself.



回答2:

for detail visit

private void Calculate3DPosition(CarouselItem child, int diameter,
            float angleOffset) {
        angleOffset = angleOffset * (float) (Math.PI / 180.0f);
        float y = (float) (diameter / 2 * Math.sin(angleOffset)) + diameter / 2
                - child.getWidth() / 2;
        float z = diameter / 2 * (1.0f - (float) Math.cos(angleOffset));
        float x = (float) (-   diameter / 2 * Math.cos(angleOffset) * 0.5);
        child.setX(x + 250);
        child.setZ(z);
        child.setY(y - 150);
    }