I have several views in FrameLayout. There is a transition that I wrote, where each view has a custom animation class. During this transition, I need to bring the representation at the bottom of the z-order to the front. I am doing this with:
public static void putBackAtFront(ViewGroup v) { v.getChildAt(0).bringToFront(); refreshEverything(v); }
This is called from applyTransformation () of my custom animation.
i.e.
public class PivotAnimation extends Animation { private View view; ... @Override protected void applyTransformation(float interpolatedTime, Transformation t) { ... if(interpolatedTime >= 1.f && isAtBack(view)) { putBackAtFront(view); } ... } ... }
refreshEverything () calls invalidate () and requestLayout () for the parent FrameLayout and all its children.
Everything works fine, except that when you call putBackAtFront (), the view that is now at the bottom disappears for one frame before instantly reappearing, which leads to a noticeable flicker. I also tried without calling refreshEverything (), it doesn't matter.
I aimed at API level 7.
source share