Reputation: 10153
I have a large custom View (a map) and a smaller View (an altimeter) drawn on top.
Is there any way to update the top View without forcing a complete redraw of the bottom View?
Upvotes: 0
Views: 340
Reputation: 10153
Also: I just discovered that if you give the View an opaque background, invalidating it won't invalidate the underlying View. It's not a perfect solution, but it's a pretty good one.
Now I need to see if it's possible to make a View with a non-rectangular shape.
Upvotes: 0
Reputation: 17861
No it's not possible (in the normal sense). When you have multiple views on top of each other, calling invalidate()
on one view will redraw all those views. When invalidate()
is called on a view, it redraws anything that lies in the dirty region
. This is taken care by the dispathDraw()
method in the the ViewGroup
. dispatchDraw()
inturn calls drawChild()
and that's why when we call invalidate()
on one view, other views also gets drawn.
That being said, you could override the dispatchDraw()
method in your own custom ViewGroup
and handle how things should behave.
Upvotes: 1