RecyclerView ItemDecoration onDraw

The spec for RecyclerView.ItemDecoration says it is onDraw(Canvas c, RecyclerView parent)

deprecated. Instead, they say to override onDraw(Canvas, RecyclerView, RecyclerView.State)

.

However, I don't understand what kind of state object I should be passing to this method. I can see the state passed internally in the RecyclerView methods like: onLayoutChildren , scrollVerticallyBy and onFocusSearchFailed . But I don't see any examples to use the State object programmatically to get to the onDraw method . Does anyone have any data on this?

0


source to share


1 answer


OnDraw()

will be called RecyclerView

with the appropriate set of states, you don't need to call it yourself. It is also advised to onDrawOver()

cancel instead RecyclerView.ItemDecoration

.



An example of a decoration that draws dividing lines between RecyclerView items: https://gist.github.com/alexfu/0f464fc3742f134ccd1e

+2


source







All Articles