【问题标题】:setPivotX doesn't work on android 4.1.1 NineOldAndroidssetPivotX 不适用于 android 4.1.1 NineOldAndroids
【发布时间】:2014-12-26 19:07:20
【问题描述】:

我正在使用scaleX()ImageView 制作动画。这应该是一个从左到右填充的进度条。它在 API 10、18 和 19 上没有问题。但在 API 16 上,setPivotX() 方法似乎有问题。我已经尝试了NineOldAndroids: set view pivot 中的所有选项。

final ImageView progressBarFill = (ImageView) getView().findViewById(R.id.progressbarImageFill);
//...

ViewHelper.setPivotX(progressBarFill, 0);
AnimatorProxy.wrap(progressBarFill).setPivotX(0);
animate(progressBarFill).setDuration(1000).scaleX(0.25f);

AnimatorSet set = new AnimatorSet();
set.playTogether(
    ObjectAnimator.ofFloat(progressBarFill, "scaleX", 0f, 0.25f)
);
AnimatorProxy.wrap(progressBarFill).setPivotX(0.0f);
ViewHelper.setPivotX(progressBarFill, 0f);
set.setDuration(1000).start();

动画有效,但它从ImageView 的中心开始动画。谁能确认这个问题?

更新

我也尝试过使用androids标准动画包:

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    progressBarFill.setVisibility(View.VISIBLE);
    progressBarFill.setPivotX(0);
    progressBarFill.setPivotY(0);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
        ObjectAnimator.ofFloat(progressBarFill, "scaleX", 0f, 0.25f)
    );
    set.setDuration(2000).start();
}

但在 android API 16 上仍然不起作用。所以问题不仅与 NineOldAndroids 库有关,还与标准动画函数有关。

【问题讨论】:

    标签: android android-animation nineoldandroids


    【解决方案1】:

    事实证明,在 API 16 中将枢轴 X 设置为 0 的效果并不好。因此,将枢轴设置在视图 progressBarFill.setPivotX(1); 的最左侧效果要好得多。

    【讨论】:

      猜你喜欢
      • 2015-02-11
      • 2014-03-08
      • 2013-03-04
      • 2013-11-05
      • 2014-04-02
      • 1970-01-01
      • 2015-04-23
      • 2018-11-17
      • 2012-01-27
      相关资源
      最近更新 更多