New Position of a image after Animation in android -
iam using translate animation bounce effect after animation finish want new top margin of image still old top margin of image 0 question how new margin
my main activity is.
package iotechsolutions.location.ira; import android.app.activity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.view; import android.view.animation.animation; import android.view.animation.animation.animationlistener; import android.view.animation.animationutils; import android.widget.imageview; import android.widget.linearlayout; import android.widget.linearlayout.layoutparams; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity { animation logoanimation; // moving logo animation textanimation; // moving text imageview mainlogo; textview logotext; linearlayout.layoutparams param; view view; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mainlogo=(imageview)findviewbyid(r.id.main_logo); logotext=(textview)findviewbyid(r.id.logo_text); param=(linearlayout.layoutparams)mainlogo.getlayoutparams(); logoanimation=animationutils.loadanimation(getapplicationcontext(),r.anim.main_logo_translate); textanimation=animationutils.loadanimation(getapplicationcontext(),r.anim.logo_text_translate); mainlogo.setanimation(logoanimation); logoanimation.setanimationlistener(new animationlistener() { @override public void onanimationend(animation arg0) { try { toast.maketext(getbasecontext(),integer.tostring( param.topmargin), toast.length_long).show(); } catch(exception e) { log.d("error",e.getmessage()); } } @override public void onanimationrepeat(animation arg0) { // todo auto-generated method stub } @override public void onanimationstart(animation arg0) { // todo auto-generated method stub } }); logoanimation.start(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
but in toast old margin position of image how new position of image.
try initializing param
before using it:
try{ param=(linearlayout.layoutparams)mainlogo.getlayoutparams(); toast.maketext(getbasecontext(),integer.tostring( param.topmargin), toast.length_long).show(); } catch{ ... }
Comments
Post a Comment