// 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/MyDecorationTwo.java
// public class MyDecorationTwo extends RecyclerView.ItemDecoration {
// 
//     private final Drawable mDivider;
// 
//     public MyDecorationTwo(Context context) {
// //        int attrs[] = new int[]{android.R.attr.listDivider};
// //        TypedArray a = context.obtainStyledAttributes(attrs);
// //        mDivider = a.getDrawable(0);
// //        a.recycle();
// 
//         mDivider = context.getResources().getDrawable(R.drawable.divider);
//     }
// 
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         drawVertical(c, parent);
//         drawHorizontal(c, parent);
//     }
// 
//     private void drawVertical(Canvas c, RecyclerView parent) {
//         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) {
//         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.getMinimumHeight();
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
//     @Override
//     public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
//         super.getItemOffsets(outRect, itemPosition, parent);
//         int right = mDivider.getIntrinsicWidth();
//         int bottom = mDivider.getIntrinsicHeight();
// 
//         if (isLastSpan(itemPosition, parent)) {
//             right = 0;
//         }
// 
//         if (isLastRow(itemPosition, parent)) {
//             bottom = 0;
//         }
//         outRect.set(0, 0, right, bottom);
//     }
// 
// //    @Override
// //    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// //        super.getItemOffsets(outRect, view, parent, state);
// //        outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
// //    }
// 
//     public boolean isLastRow(int itemPosition, RecyclerView parent) {
//         RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
//         if (layoutManager instanceof GridLayoutManager) {
//             int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
//             int itemCount = parent.getAdapter().getItemCount();
//             if ((itemCount - itemPosition - 1) < spanCount)
//                 return true;
//         }
//         return false;
//     }
// 
//     public boolean isLastSpan(int itemPosition, RecyclerView parent) {
//         RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
//         if (layoutManager instanceof GridLayoutManager) {
//             int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
//             if ((itemPosition + 1) % spanCount == 0)
//                 return true;
//         }
//         return false;
//     }
// }


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




/**
 * @创建者 CSDN_LQR
 * @描述 RecyclerView的表格样式
 */
public class RecyclerVIewDecorationActivityTwo extends AppCompatActivity {

    private List<String> mData = new ArrayList<>();
    private RecyclerView mRv;
// 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/MyDecorationTwo.java
// public class MyDecorationTwo extends RecyclerView.ItemDecoration {
// 
//     private final Drawable mDivider;
// 
//     public MyDecorationTwo(Context context) {
// //        int attrs[] = new int[]{android.R.attr.listDivider};
// //        TypedArray a = context.obtainStyledAttributes(attrs);
// //        mDivider = a.getDrawable(0);
// //        a.recycle();
// 
//         mDivider = context.getResources().getDrawable(R.drawable.divider);
//     }
// 
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         drawVertical(c, parent);
//         drawHorizontal(c, parent);
//     }
// 
//     private void drawVertical(Canvas c, RecyclerView parent) {
//         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) {
//         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.getMinimumHeight();
//             mDivider.setBounds(left, top, right, bottom);
//             mDivider.draw(c);
//         }
//     }
// 
//     @Override
//     public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
//         super.getItemOffsets(outRect, itemPosition, parent);
//         int right = mDivider.getIntrinsicWidth();
//         int bottom = mDivider.getIntrinsicHeight();
// 
//         if (isLastSpan(itemPosition, parent)) {
//             right = 0;
//         }
// 
//         if (isLastRow(itemPosition, parent)) {
//             bottom = 0;
//         }
//         outRect.set(0, 0, right, bottom);
//     }
// 
// //    @Override
// //    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// //        super.getItemOffsets(outRect, view, parent, state);
// //        outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
// //    }
// 
//     public boolean isLastRow(int itemPosition, RecyclerView parent) {
//         RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
//         if (layoutManager instanceof GridLayoutManager) {
//             int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
//             int itemCount = parent.getAdapter().getItemCount();
//             if ((itemCount - itemPosition - 1) < spanCount)
//                 return true;
//         }
//         return false;
//     }
// 
//     public boolean isLastSpan(int itemPosition, RecyclerView parent) {
//         RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
//         if (layoutManager instanceof GridLayoutManager) {
//             int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
//             if ((itemPosition + 1) % spanCount == 0)
//                 return true;
//         }
//         return false;
//     }
// }


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

package com.lqr.materialdesigndemo.activity;




/**
 * @创建者 CSDN_LQR
 * @描述 RecyclerView的表格样式
 */
public class RecyclerVIewDecorationActivityTwo extends AppCompatActivity {

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