I have several Views within a FrameLayout. There is a transition I have written where each view has a custom Animation class applied. During this transition, I need to bring the View at the bottom of the z-order to the front. I do this with:
public static void putBackAtFront(ViewGroup v)
{
v.getChildAt(0).bringToFront();
refreshEverything(v);
}
This gets called from within the 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() on the parent FrameLayout and all its children.
Everything works perfectly except that when putBackAtFront() is called, the View that is now at the bottom disappears for a single frame before instantly re-appearing, resulting in a noticeable flicker. I've also tried without calling refreshEverything(), it makes no difference.
I'm targeting API Level 7.