Q:

android - LinearLayout become visible when calling removeView() after fade out

I have a view which need to fade out before I remove it, here is the code:
private void startViewFadeOut(final View v, final LinearLayout layout)
{
    AnimationTask fadeTask = new AnimationTask(_handler,
                                               FADE_OUT_DURATION
                                               , FADE_PERIOD)
    {
        @Override
        protected boolean onRun(float progress)
        {
            float fadeAlpha = 1 - progress;
            v.setAlpha(fadeAlpha);

            if (progress >= 1f)
            {
                layout.removeView(v);  -- line A
                return false;
            }
            return true;
        }
    };
    fadeTask.start();
}

The AnimationTask is just a wrapper of Runnable.
The fading out is working well, but at line A this view will blink, it become visible again and then disappear, I've tried to use v.setVisibility(View.GONE), it's not working eighter.
Anybody has any idea about this?

A:

It's a bit unclear from your sample, but I suspect this will all work better if you post the runnable to the activity rather than creating a separate task so it will all be in the same thread.
I'd also definitely use setVisibility(view.gone).

