Maria Neumayer
Maria Neumayer

Reputation: 3357

Android draws last visible state after visibility change

I have a custom ViewGroup which is not visible at all times. When the view is not visible I clear all children by calling removeAllViews(). The problem is when I change the visibility the old content is being drawn first, before updating to the new content, which results in the screen flashing. I tried calling destroyDrawingCache() which didn't help. Is there anything I'm missing here?

As for my custom ViewGroup - the only thing this is doing is overwriting onMeasure() and onLayout() to lay out the children correctly.

Upvotes: 3

Views: 198

Answers (1)

Maria Neumayer
Maria Neumayer

Reputation: 3357

Found the issue! When I was adding the children I had a ScaleAnimation with the fillAfter flag set to true. This was causing the issue. Removing the fillAfter flag resolved the issue. It was only happening on ICS+ FYI, so probably an issue of hardware acceleration.

Upvotes: 1

Related Questions