标签:param margin back ott cal top mode int ext.get
/**
* 垂直布局分割线绘制
* @param c
* @param parent
*/
private void drawVertical(Canvas c,RecyclerView parent){
final int left=parent.getPaddingLeft();
final int right=parent.getWidth()-parent.getPaddingRight();
final int childCount=parent.getChildCount();
for(int i=0;i<childCount;i++){
final View child=parent.getChildAt(i);
final RecyclerView.LayoutParams params= (RecyclerView.LayoutParams) child.getLayoutParams();
final int top=child.getBottom()+params.bottomMargin+Math.round(ViewCompat.getTranslationZ(child));
final int bottom=top+drawable.getIntrinsicHeight();
drawable.setBounds(left,top+2,right,bottom);//宽度调节
drawable.setColorFilter(context.getResources().getColor(R.color.colorAccent), PorterDuff.Mode.XOR);//Mode选择不对无法正常显示选择的颜色
drawable.draw(c);
如代码所示,宽度其实就是控制top和bottom的距离,加减就可以了,很简单。
颜色就是drawable设置setColorFilter设置颜色和Mode,注意有的Mode颜色显示不正常
标签:param margin back ott cal top mode int ext.get
原文地址:http://www.cnblogs.com/a1070022846/p/7766654.html