Reputation: 2799
I am animating an ImageView
using scaleX()
. 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. I have tried every option in 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
. Can anyone confirm this issue?
UPDATE
I have tried to use androids standard animation package as well:
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.
Upvotes: 1
Views: 860
Reputation: 2799
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);
worked a lot better.
Upvotes: 3