// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
// 
//     private List<String> mData;
// 
//     public MyAdapter(List<String> data) {
//         mData = data;
//     }
// 
//     @Override
//     public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
//         itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
//         return new MyViewHolder(itemView);
//     }
// 
//     @Override
//     public void onBindViewHolder(MyViewHolder holder, int position) {
//         holder.mTv.setText(mData.get(position));
//     }
// 
//     @Override
//     public int getItemCount() {
//         return mData.size();
//     }
// 
//     class MyViewHolder extends RecyclerView.ViewHolder {
// 
//         TextView mTv;
// 
//         public MyViewHolder(View itemView) {
//             super(itemView);
//             mTv = (TextView) itemView.findViewById(android.R.id.text1);
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
// 
//     int orientation = RecyclerView.HORIZONTAL;
//     private final Drawable mDivider;
// 
//     public MyDecorationOne(Context context, int orientation) {
//         this.orientation = orientation;
//         int[] attrs = new int[]{android.R.attr.listDivider};
//         TypedArray a = context.obtainStyledAttributes(attrs);
//         mDivider = a.getDrawable(0);
//         a.recycle();
//     }
// 
//     /**
//      * 画线
//      */
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         if (orientation == RecyclerView.HORIZONTAL) {
//             drawVertical(c, parent, state);
//         } else if (orientation == RecyclerView.VERTICAL) {
//             drawHorizontal(c, parent, state);
//         }
//     }
// 
//     private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         int childCount = parent.getChildCount();
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
//             int left = child.getRight() + params.rightMargin;
//             int top = child.getTop() - params.topMargin;
//             int right = left + mDivider.getIntrinsicWidth();
//             int bottom = child.getBottom() + params.bottomMargin;
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
//     private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         int childCount = parent.getChildCount();
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
//             int left = child.getLeft() - params.leftMargin;
//             int top = child.getBottom() + params.bottomMargin;
//             int right = child.getRight() + params.rightMargin;
//             int bottom = top + mDivider.getIntrinsicHeight();
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
// 
//     /**
//      * 设置条目周边的偏移量
//      */
//     @Override
//     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//         super.getItemOffsets(outRect, view, parent, state);
//         if (orientation == RecyclerView.HORIZONTAL) {
//             //画垂直线
//             outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
//         } else if (orientation == RecyclerView.VERTICAL) {
//             //画水平线
//             outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
//         }
//     }
// }


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;
package com.lqr.materialdesigndemo.activity;




/**
 * @创建者 CSDN_LQR
 * @描述 RecyclerView的分割线
 */
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {

    private List<String> mData = new ArrayList<>();
    private RecyclerView mRv;
    private MyAdapter mMyAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        mRv = (RecyclerView) findViewById(R.id.rv);
        initView();
        initData();
        setRecyclerView();
    }

// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
// 
//     private List<String> mData;
// 
//     public MyAdapter(List<String> data) {
//         mData = data;
//     }
// 
//     @Override
//     public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
//         itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
//         return new MyViewHolder(itemView);
//     }
// 
//     @Override
//     public void onBindViewHolder(MyViewHolder holder, int position) {
//         holder.mTv.setText(mData.get(position));
//     }
// 
//     @Override
//     public int getItemCount() {
//         return mData.size();
//     }
// 
//     class MyViewHolder extends RecyclerView.ViewHolder {
// 
//         TextView mTv;
// 
//         public MyViewHolder(View itemView) {
//             super(itemView);
//             mTv = (TextView) itemView.findViewById(android.R.id.text1);
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
// 
//     int orientation = RecyclerView.HORIZONTAL;
//     private final Drawable mDivider;
// 
//     public MyDecorationOne(Context context, int orientation) {
//         this.orientation = orientation;
//         int[] attrs = new int[]{android.R.attr.listDivider};
//         TypedArray a = context.obtainStyledAttributes(attrs);
//         mDivider = a.getDrawable(0);
//         a.recycle();
//     }
// 
//     /**
//      * 画线
//      */
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         if (orientation == RecyclerView.HORIZONTAL) {
//             drawVertical(c, parent, state);
//         } else if (orientation == RecyclerView.VERTICAL) {
//             drawHorizontal(c, parent, state);
//         }
//     }
// 
//     private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         int childCount = parent.getChildCount();
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
//             int left = child.getRight() + params.rightMargin;
//             int top = child.getTop() - params.topMargin;
//             int right = left + mDivider.getIntrinsicWidth();
//             int bottom = child.getBottom() + params.bottomMargin;
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
//     private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         int childCount = parent.getChildCount();
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
//             int left = child.getLeft() - params.leftMargin;
//             int top = child.getBottom() + params.bottomMargin;
//             int right = child.getRight() + params.rightMargin;
//             int bottom = top + mDivider.getIntrinsicHeight();
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
// 
//     /**
//      * 设置条目周边的偏移量
//      */
//     @Override
//     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//         super.getItemOffsets(outRect, view, parent, state);
//         if (orientation == RecyclerView.HORIZONTAL) {
//             //画垂直线
//             outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
//         } else if (orientation == RecyclerView.VERTICAL) {
//             //画水平线
//             outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
//         }
//     }
// }


// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;

package com.lqr.materialdesigndemo.activity;




/**
 * @创建者 CSDN_LQR
 * @描述 RecyclerView的分割线
 */
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {

    private List<String> mData = new ArrayList<>();
    private RecyclerView mRv;
    private MyAdapter mMyAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        mRv = (RecyclerView) findViewById(R.id.rv);
        initView();
        initData();
        setRecyclerView();
    }

    private void initView() {