Simple&Natural

[Android] ItemDecoration의 onDraw와 onDrawOver의 차이 본문

안드로이드(Android)/기타

[Android] ItemDecoration의 onDraw와 onDrawOver의 차이

Essense 2020. 11. 22. 09:27
728x90

차이는 생각보다 간단하다.

onDraw의 경우 ItemView가 그려지기 이전에 그려진다. 따라서 ItemView의 아래에 보이게 된다.

onDrawOver의 경우는 반대로 ItemView보다 나중에 그려지며 ItemView의 위에 덮어 씌워진다.

 

onDraw

/**
* Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
* Any content drawn by this method will be drawn before the item views are drawn,
* and will thus appear underneath the views.
*
* @param c Canvas to draw into
* @param parent RecyclerView this ItemDecoration is drawing into
* @param state The current state of RecyclerView
*/

 

onDrawOver

/**
* Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
* Any content drawn by this method will be drawn after the item views are drawn
* and will thus appear over the views.
*
* @param c Canvas to draw into
* @param parent RecyclerView this ItemDecoration is drawing into
* @param state The current state of RecyclerView.
*/

728x90