I have an imageView inside of a LinearLayout and when I call invalidate on that LinearLayout it doesnt invalidate until the phone sleeps and wake again.
Is there anyway of forcing the LinearLayout to invalidate straight away?
I have an imageView inside of a LinearLayout and when I call invalidate on that LinearLayout it doesnt invalidate until the phone sleeps and wake again.
Is there anyway of forcing the LinearLayout to invalidate straight away?
From android documentation about invalidate function
Invalidate the whole view. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
This is over 3 years old, so I'm not anticipating a response, but if you don't think your LinearLayout
is invalidating because you're not getting any calls to onDraw()
, take a look at https://stackoverflow.com/a/17595671/852795:
By default all ViewGroup sub-classes do not call their
onDraw
method, you should enable it by callingsetWillNotDraw(false)
link
From the doc:
By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you override
onDraw(android.graphics.Canvas)
you should clear this flag.
Try adding setWillNotDraw(false);
to your LinearLayout.