Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Android | Competitive Programming

Arpit Johri Arpit0492

💭
Android | Competitive Programming
View GitHub Profile
@Arpit0492
Arpit0492 / EqualSpacingItemDecoration.java
Last active May 14, 2020
Add equal spacing to RecyclerView items by specifying top, left, right & bottom margins. Can handle horizontal, vertical, and grid display modes
View EqualSpacingItemDecoration.java
import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class EqualSpacingItemDecoration extends RecyclerView.ItemDecoration {
private final int topSpacing;
private final int leftSpacing;
private final int rightSpacing;