android - Adding an inflating view with an animation -


i have view inflate when use clicks button, , want animate view screen when button clicked, have tried code below view snaps screen instead of animates on screen. not sure why view not animate position. view want animate previewmemberpanel

 previewmemberpanel = ((layoutinflater) this.getsystemservice(context.layout_inflater_service))             .inflate(r.layout.main_member_listing_imagepreview, null, false);   //button click body     animation anim = new translateanimation(new displaymetrics().widthpixels / 2, 0, 0, 0);     anim.setfillafter(true);     anim.setduration(5000);     anim.setstartoffset(500);     if( !previewmemberpanel.isshown() ){         ((linearlayout) findviewbyid(r.id.rootmembers)).addview(previewmemberpanel);                 previewmemberpanel.startanimation(anim);     } 

use handler post animation:

((linearlayout) findviewbyid(r.id.rootmembers)).addview(previewmemberpanel);  new handler().post(new runnable() {   public void run() {     previewmemberpanel.startanimation(anim);   } }); 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -