简体   繁体   English

setPivotX不适用于android 4.1.1 NineOldAndroids

[英]setPivotX doesn't work on android 4.1.1 NineOldAndroids

I am animating an ImageView using scaleX() . 我使用scaleX()动画一个ImageView This is supposed to be a progress bar which fills from left to right. 这应该是一个从左到右填充的进度条。 It works without a problem on API 10, 18 and 19. But on API 16 there seems to be a problem with the setPivotX() method. 它在API setPivotX()和19上没有问题。但是在API 16上, setPivotX()方法似乎存在问题。 I have tried every option in NineOldAndroids: set view pivot . 我已尝试过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);

and

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();

The animation works but it animates from the center of the ImageView . 动画可以工作,但它从ImageView的中心动画。 Can anyone confirm this issue? 有谁能证实这个问题?

UPDATE UPDATE

I have tried to use androids standard animation package as well: 我也试过使用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();
}

But is still doesnt work on android API 16. So the problem is not only related to the NineOldAndroids library but the standard animation function as well. 但是仍然无法在Android API 16上运行。所以问题不仅与NineOldAndroids库有关,而且与标准动画函数有关。

Turnes out that setting the pivot X to 0 doesnt go down very well in API 16. So to set the pivot to the very left in the view progressBarFill.setPivotX(1); Turnes指出,将枢轴X设置为0在API 16中并没有很好地下降。因此,要在视图中将枢轴设置为最左边的progressBarFill.setPivotX(1); worked a lot better. 工作得更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM