android - How can I achieve this ListView animation? -


what's guys, need little one. i'm trying achieve simple(but not really) folding animation on listview being scrolled. basically, i'm attempting fold listview's first visible child backward if sheet of paper being folded downward along x axis. goes on on continuously user scrolls , down list. first time playing around matrix animations , android's camera graphics api, i'm off mark here.

this effect i'm trying achieve

this effect i'm trying achieve

and effect i'm getting. and effect i'm getting

i want animation begin @ origin(0,0) both left , right side, animating top of list item instead of upper left corner. i'm not familiar matrix translations or animations if more experience these techniques myself can shed knowledge, it'll appreciated.

basically i'm overriding ondrawchild method of listview, grabbing child's bitmap drawing cache, , using matrix perform animation. lighting , camera implementation code took sample app in order animation 3d possible.

i tried playing around listview animations library, without luck. tried hack solution using code developer guides here uses object animators achieve nice little card flip animation, started feeling bit hacky , couldn't quite way wanted.

here's current implementation. if can shed light or direction on one, or maybe if wrote awesome library didn't come across on searches, please feel free share. thanks

   @override protected boolean drawchild(canvas canvas, view child, long drawingtime) {      view first = getchildat(0);      if (child == first) {         if (child.gettop() < 0) {              bitmap bitmap = getchilddrawingcache(child);             final int top = child.gettop();             child.getright();             child.getbottom();             child.getleft();              final int childcentery = child.getheight() / 2;             // final int childcenterx = child.getwidth() / 2;             final int parentcentery = getheight() / 2; // center point of             // child relative list              final int abschildcentery = child.gettop() + childcentery;              // final int bottom = child.getbottom();              // distance of child center list center final int             int distancey = parentcentery - abschildcentery;              final int r = getheight() / 2;              if (manimate) {                  preparematrix(mmatrix, distancey, r);                    mmatrix.pretranslate(0, top);                  mmatrix.posttranslate(0, -top);                }             canvas.drawbitmap(bitmap, mmatrix, mpaint);          }          else {             super.drawchild(canvas, child, drawingtime);         }     } else {         super.drawchild(canvas, child, drawingtime);     }     return false;  }  private void preparematrix(final matrix outmatrix, int distancey, int r) { // clip                                                                             //                                                                             // distance      final int d = math.min(r, math.abs(distancey)); //     // circle formula     final float translatez = (float) math.sqrt((r * r) - (d * d));      double radians = math.acos((float) d / r);     double degree = 45 - (180 / math.pi) * radians;      // double degree = -180;      mcamera.save();     mcamera.translate(0, 0, r - translatez);     mcamera.rotatex((float) degree);     if (distancey < 0) {         degree = 360 - degree;     }     mcamera.rotatey((float) degree);     mcamera.getmatrix(outmatrix);     mcamera.restore();      // highlight elements in middle     mpaint.setcolorfilter(calculatelight((float) degree)); }  private bitmap getchilddrawingcache(final view child) {     bitmap bitmap = child.getdrawingcache();     if (bitmap == null) {         child.setdrawingcacheenabled(true);         child.builddrawingcache();         bitmap = child.getdrawingcache();     }     return bitmap; }  private lightingcolorfilter calculatelight(final float rotation) {     final double cosrotation = math.cos(math.pi * rotation / 180);     int intensity = ambient_light + (int) (diffuse_light * cosrotation);     int highlightintensity = (int) (specular_light * math.pow(cosrotation,             shininess));     if (intensity > max_intensity) {         intensity = max_intensity;     }     if (highlightintensity > max_intensity) {         highlightintensity = max_intensity;     }     final int light = color.rgb(intensity, intensity, intensity);     final int highlight = color.rgb(highlightintensity, highlightintensity,             highlightintensity);     return new lightingcolorfilter(light, highlight); } 

jazzylistview

has lot of stuff that's similar want if not want. take @ how they're defined under jazzy effect , mix , match. think reverse fly or maybe flip close want.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -