Android : ItemDecoration offset is twice as big

on Friday, January 30, 2015


To add a separator on my RecyclerView, I've subclassed the RecyclerView.ItemDecoration class and overrided GetItemsOffsets.



public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, State state)
{
if (parent.GetChildPosition(view) > 0)
{
outRect.Set(0, 0, 0, _separatorHeight);
}
}


The problem is that the specified height is 2dp (4px on my xhdpi screen), but the space I get on the screen is actually 8px.


0 comments:

Post a Comment