Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NineOldAndroids, not clickable view after rotation or move

I use NineOldAndroids 2.4.0 to animate objects mainly for the movement and transformation of control. On Android 4.0 and above all works fine,but on previous versions (2.1, 2.3) after the animation elements do not receive focus and do not clickable. Sample code:

View v = findViewById(R.id.button1);
v.setOnClickListener(new OnClickListener() {

     @Override
     public void onClick(View v) {
        Toast.makeText(MainActivity.this, "Click!", Toast.LENGTH_SHORT).show();
     }
});
ObjectAnimator moveDown = ObjectAnimator.ofFloat(v, "translationY", 100f);
moveDown.setDuration(5000);
moveDown.start();

This is a bug in the library or something I'm doing wrong? If this library does not support all the functionality of "Honeycomb animation API", then in my project, it will be useless.

Quote on Android Developer Blog of "Animation in Honeycomb": Since the system is actually changing properties on target objects, the objects themselves are changed, not simply their appearance. So that button you move is actually moved, not just drawn in a different place. You can even click it in its animated location. Go ahead and click it; I dare you.

like image 428
avesha Avatar asked Nov 01 '12 08:11

avesha


1 Answers

now i found the answer: How to do interactive animation (translation) with Android

it says that nineoldandroids got the same limitations as the native SDK.

so my solution:

myAnim.setListener(new AnimatorListenerAdapter() {
  @Override
  public void onAnimationEnd ( Animator nullPointer ) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) child.getLayoutParams();
    params.bottomMargin += toYDelta;
    params.leftMargin += toXDelta;
    child.setLayoutParams(params);
  }
});
like image 75
Mario Avatar answered Nov 02 '22 10:11

Mario