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.
applyTransformation() is called multiple times during the animation so you should do the animation based on the interpolatedTime, when its 1.0, the animation is at the end, so you should call your bring to front here.
So in my opinion this flicker happens when in some of these calls to your method, the getChildAt(0) gets a different view than the one you want and the flicker appears.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With