谷歌有关于此的文档,
https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-keylines-spacing
但是没有解释如何做到这一点,
这是我到目前为止的尝试,我不确定边距/填充和分隔符,是否有任何教程如何进行此布局
这是RecyclerView项目布局:
v2.frame = CGRect(-2000, 0, 70, 70)
答案 0 :(得分:3)
要获得部分分隔符(或任何名称),我使用它:
创建一个类扩展#sort FILEs first before comparing
sort $FILE_1 > $FILE_1_sorted
sort $FILE_2 > $FILE_2_sorted
for oid in $(cat $FILE_1_sorted |awk -F"|" '{print $1}');
do
echo "output oid $oid"
#for every oid in FILE 1, compare it with oid FILE 2 and output the difference
grep -v diff "^${oid}|" $FILE_1 $FILE_2 | grep \< | cut -d \ -f 2 > $FILE_1_tmp
RecyclerView.ItemDecoration
然后你只需要像这样使用它:
public class RecyclerViewItemDivider extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
private Drawable mDivider;
public RecyclerViewItemDivider(Context context) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
// this is the left start point for divider,
// I think there is better method without hardcoded the view
// main_content is my RectclerView item main content
// R.dimen.activity_horizontal_margin should be 16dp if use google guidelines
int left = (int)parent.findViewById(R.id.main_content).getX() +
(int)parent.getContext().getResources().getDimension(R.dimen.activity_horizontal_margin);
int right = parent.getWidth() - parent.getPaddingRight();
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
int top = child.getBottom() + params.bottomMargin;
int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
}