Last active
May 12, 2016 07:25
-
-
Save twiceyuan/9f9e7b6e7b6a05c84836cd1763bc9832 to your computer and use it in GitHub Desktop.
RecyclerView 中间分隔间隙的实现方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 间隔为1 | |
mRecyclerView.addItemDecoration(new VerticalItemDecoration(DP.dp2px(getContext(), 1))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
/** | |
* Created by twiceYuan on 3/30/16. | |
* Email: [email protected] | |
* Site: http://twiceyuan.com | |
* | |
* RecyclerView 分割线高度设定 | |
*/ | |
public class VerticalItemDecoration extends RecyclerView.ItemDecoration { | |
private final int mVerticalSpaceHeight; | |
public VerticalItemDecoration(int mVerticalSpaceHeight) { | |
this.mVerticalSpaceHeight = mVerticalSpaceHeight; | |
} | |
@Override | |
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, | |
RecyclerView.State state) { | |
outRect.bottom = mVerticalSpaceHeight; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment