Setting up a cover flow in Android

2019-02-07 15:03发布

问题:

I created an iphone application, and now I am consigned to do the same application in android. I used the OpenFlow from thefaj on github https://github.com/thefaj/OpenFlow

however I have yet to be able to find something with a working coverflow on the android..

Does anyone have experience with this in android or know a good place to start ?

回答1:

I used this code on my project http://www.inter-fuser.com/2010/02/android-coverflow-widget-v2.html

You can adapt it to load the contents from some datasource, it's not a hard work.



回答2:

Just came across http://code.google.com/p/android-coverflow/ which seems to be based in the inter-fuser code with some optimisations



回答3:

Extend Gallery, and override this method as so:

   protected boolean getChildStaticTransformation(View child, Transformation t) {
    t.clear();
    t.setTransformationType(Transformation.TYPE_MATRIX);
    final Matrix matrix = t.getMatrix();
    float childCenterPos = child.getLeft() + (child.getWidth() / 2f);
    float center = getWidth() / 2;
    float diff = Math.abs(center - childCenterPos);
    float scale = diff / getWidth();

    matrix.setScale(1 - (scale), 1 - (scale));

    return true;
}

Obviously you can do more interresting stuff with the matrix than just scaling, but this just as an example of how easy it can be done.