With Object Property Animators, basically, it's just mathematical functions that repeatedly call the setN () method every X miliseconds, where "N" is the property you want to change.
In the example presented in the alpha case, calling invalidate() requires redrawing the view you are animating. The difference is that you call setAlpha() on the View object, it calls invalidate() for you. If you were to set the Paint target, which is used for drawing, you still need to call invalidate() on the View to redraw the new Paint parameters.
Ideally, you want to set the goal to a child level of the highest level, so that redrawing only occurs on the views you want to animate. For example, if you set the target in the root view, it will call invalidate() for each child in the entire ViewGroup, which in turn will call draw() for each child in the ViewGroup. If you set it to the top level of ImageView , only ImageView will be redrawn.
To make better use of the equipment, you need to use the Layer properties. First, you need to decide what will be the most parental species that you want to animate. If you only want to fade Drawable , then it will be Drawable or contains a View . If you want everything to disappear, then this will be the root view. Everything that you decide to revive will be applied to the View as a whole immediately.
Use setLayerType() in the parent view just before starting Animator. Set it to View#LAYER_TYPE_HARDWARE . Then set the AnimationListener and reset LayerType to View#LAYER_TYPE_SOFTWARE or View#LAYER_TYPE_NONE after the animator completes.
myParentView.setLayerType(View.LAYER_TYPE_HARDWARE, null); myObjectAnimator.addListener(new ViewAnimator.AnimatorListener() { public void onAnimationEnd(Animator animation) { myParentView.setLayerType(View.LAYER_TYPE_NONE); } public void onAnimationRepeat(Animator animation) { } public void onAnimationStart(Animator animation) { } public void onAnimationCancel(Animator animation) { myParentView.setLayerType(View.LAYER_TYPE_NONE, null); } } myObjectAnimator.start();
In this case, if you were to translate myParentView using the translateX property, it will put the myParentView layer and all its children on the same plane. Put it in the hardware memory. Translate the whole view at once. Then, upon completion, remove myParentView from memory.
EDIT:
Finally, Alpha cripples the processor. If you have something half alpha and translate it through View, it will be harder to do than if you just translated View. Use it sparingly.