问题
I have made some tests with the ObjectAnimator class on some devices and everything is OK except for one device : Huawei P8 Lite 2017.
On this device, the View "disappears" when the animation starts and "appears" at the end. The issue appears only when I'm using AnimatorSet/Animator (Java code or XML), but animations which use the old Animation class (TranslateAnimation, AlphaAnimation...) are working well.
Here is the list of devices where there is no issue : Nexus 5 Nexus 5X Nexus 9 HTC One M9 Samsung GS4 Pixel XL Alcatel OneTouch Idol 5
What is the problem with this Huawei ?
Edit : I have made some other tests, the issue seems to be only with Rotation animation.
ObjectAnimator r = ObjectAnimator.ofFloat(myView, View.ROTATION_Y, 540);
r.setDuration(5000);
r.start();
works on every devices except the Huawei.
If I replace ROTATION_Y by ALPHA or TRANSLATION_X or Y, it is working on the Huawei.
Here is a link with more or less the same issue : ObjectAnimator causes ImageView to disappear
回答1:
I had the same problem with Huawei devices (P9 Lite).
The problem is "camera distance" during transformation. Default value for camera distance for Huawei is too small and you should set it by code:
image.setCameraDistance(float)
From documentation:
If you want to specify a distance that leads to visually consistent results across various densities, use the following formula:
float scale = context.getResources().getDisplayMetrics().density;
view.setCameraDistance(distance * scale);
来源:https://stackoverflow.com/questions/46845261/animator-animatorset-issue-on-some-devices