limedroid / ARecyclerView

一个库搞定recyclerview
MIT License
185 stars 56 forks source link

建议:网格视图下 可以封装个间距设置方法 #11

Open Sum41forever opened 7 years ago

Sum41forever commented 7 years ago

现在好像只有线性的

public XRecyclerView noDivider() {
    setItemAnimator(new DefaultItemAnimator());
    setHasFixedSize(true);
    return this;
}

public XRecyclerView horizontalDivider(@ColorRes int colorRes, @DimenRes int dimenRes) {
    setItemAnimator(new DefaultItemAnimator());
    setHasFixedSize(true);
    addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext())
            .colorResId(colorRes)
            .size(getContext().getResources().getDimensionPixelSize(dimenRes))
            .build()
    );
    return this;
}

public XRecyclerView verticalDivider(@ColorRes int colorRes, @DimenRes int dimenRes) {
    setItemAnimator(new DefaultItemAnimator());
    setHasFixedSize(true);
    addItemDecoration(new VerticalDividerItemDecoration.Builder(getContext())
            .colorResId(colorRes)
            .size(getContext().getResources().getDimensionPixelSize(dimenRes))
            .build()
    );
    return this;
}
limedroid commented 7 years ago

感谢反馈 @Sum41forever