NineOldAndroids, not clickable view after rotation or move

ave*_*sha 8 animation android

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();
Run Code Online (Sandbox Code Playgroud)

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.

报价上的Android开发者博客"在蜂巢动画": 由于目标对象的系统实际上是改变性质,对象本身的改变,不只是它们的外观.因此,您移动的按钮实际上是移动的,而不仅仅是在不同的地方绘制.您甚至可以在其动画位置单击它.继续点击它; 我赌你.

Mar*_*rio 7

现在我找到了答案: 如何使用Android进行交互式动画(翻译)

它说九个机器人与原生SDK有相同的限制.

所以我的解决方案

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);
  }
});
Run Code Online (Sandbox Code Playgroud)

  • 是的,这是一个平台限制.当动画在预蜂窝结束时,您需要物理移动视图. (3认同)
  • 请注意,更改View的边距以重新定位View,如果要在其父级内移动视图**,但是如果您需要重新定位View以使其部分移动到其父级边界框外,则可能会遇到调整View大小的问题. (2认同)