void
void

Reputation: 1377

Is there any way to redraw only one View?

I have GroupView which contains 4 ImageViews.

When I change params of one view(for example re scale image or rotate) this causes to redraw whole Layout.

I want to prevent redrawing whole layout and want to redraw only specific View.

Upvotes: 1

Views: 964

Answers (1)

marmor
marmor

Reputation: 28239

Sure.

myView.invalidate()

See: https://developer.android.com/reference/android/view/View.html#invalidate()

Drawing is handled by walking the tree and recording the drawing commands of any View that needs to update. After this, the drawing commands of the entire tree are issued to screen, clipped to the newly damaged area.

The tree is largely recorded and drawn in order, with parents drawn before (i.e., behind) their children, with siblings drawn in the order they appear in the tree. If you set a background drawable for a View, then the View will draw it before calling back to its onDraw() method. The child drawing order can be overridden with custom child drawing order in a ViewGroup, and with setZ(float) custom Z values} set on Views.

To force a view to draw, call invalidate().

Upvotes: 2

Related Questions