android - How to preserve the ending values of an animation? -


i use api 10. have imageview nested inside of linearlayout. imageview has onclicklistener (or ontouchlistener, i'm sure 1 ll use @ end). imageview centered on screen, , when clicked performs following animation.

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:fillenabled="true"     android:fillafter="true"     >     <alpha         android:fromalpha="1"         android:toalpha="0"          android:duration ="500"         />      <translate          android:fromxdelta="0%"         android:toxdelta="-100%p"         android:duration ="1000"     /> </set> 

the problem after animation ends, returns first position, faded out 0, still clickable if doesn't show up. click on empty space imageview first positioned, , performs the animation again. clicking ghost. how make imageview stays @ position written @ android:toxdelta ??

you can set animationlistener animation tackle problem, created simple fonction:

public void startanimation(final view v, final int animationresourceid, animationlistener l){     animation anim;      if(v!=null){    // can null, after change of orientation         anim = animationutils.loadanimation(v.getcontext(),resid);         v.setanimation(anim);         anim.setanimationlistener(l);         v.startanimation(anim);                      } } 

then every time need animate view, can this:

startanimation(myview, r.anim.my_anim, new animationlistener() {              @override             public void onanimationstart(animation animation) {              }              @override             public void onanimationrepeat(animation animation) {              }              @override             public void onanimationend(animation animation) {                 myview.setvisibility(view.gone);                 }         }); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -