android - How to animate simple View to move from bottom to top? -
i need implement type of progress bar. should simple view, moves top bottom infinitely. have concept art feature: https://lh6.googleusercontent.com/-gjj5hsumgyc/vxn_pirtxri/aaaaaaaadmu/r9rp3gbdu3c/w445-h791-no/castro_splash.gif
yellow zone should move bottom. how can animate this?
use method:
private void moveviewtoscreencenter( view view ) { relativelayout root = (relativelayout) findviewbyid( r.id.rootlayout ); displaymetrics dm = new displaymetrics(); this.getwindowmanager().getdefaultdisplay().getmetrics( dm ); int statusbaroffset = dm.heightpixels - root.getmeasuredheight(); int originalpos[] = new int[2]; view.getlocationonscreen( originalpos ); int xdest = dm.widthpixels/2; xdest -= (view.getmeasuredwidth()/2); int ydest = dm.heightpixels - (view.getmeasuredheight()/2) - statusbaroffset; translateanimation anim = new translateanimation( 0, xdest - originalpos[0] , 0, ydest - originalpos[1] ); anim.setduration(1000); anim.setfillafter( true ); view.startanimation(anim); }
Comments
Post a Comment