Simple Horizontal Divider Item Decoration for RecyclerView
mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
getApplicationContext()
));
NOTE: Add item decoration prior to setting the adapter
| /* | |
| * Copyright (C) 2014 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| import android.content.Context; | |
| import android.graphics.Bitmap; | |
| import android.graphics.Canvas; | |
| import android.graphics.Color; | |
| import android.graphics.Matrix; | |
| import android.graphics.Paint; | |
| import android.graphics.Paint.Align; | |
| import android.graphics.Paint.FontMetrics; | |
| import android.graphics.Typeface; | |
| import android.graphics.drawable.BitmapDrawable; |
| /** | |
| * ItemDecoration implementation that applies and inset margin | |
| * around each child of the RecyclerView. It also draws item dividers | |
| * that are expected from a vertical list implementation, such as | |
| * ListView. | |
| */ | |
| public class DividerDecoration extends RecyclerView.ItemDecoration { | |
| private static final int[] ATTRS = { android.R.attr.listDivider }; |
| /** | |
| * ItemDecoration implementation that applies and inset margin | |
| * around each child of the RecyclerView. It also draws item dividers | |
| * that are expected from a vertical list implementation, such as | |
| * ListView. | |
| */ | |
| public class GridDividerDecoration extends RecyclerView.ItemDecoration { | |
| private static final int[] ATTRS = { android.R.attr.listDivider }; |
| /** | |
| * A {@link android.support.v7.widget.RecyclerView.LayoutManager} implementation | |
| * that places children in a two-dimensional grid, sized to a fixed column count | |
| * value. User scrolling is possible in both horizontal and vertical directions | |
| * to view the data set. | |
| * | |
| * <p>The column count is controllable via {@link #setTotalColumnCount(int)}. The layout manager | |
| * will generate the number of rows necessary to accommodate the data set based on | |
| * the fixed column count. | |
| * |
| public class measureSize{ | |
| public void getSize1(){ | |
| int w = View.MeasureSpec.makeMeasureSpec(0, | |
| View.MeasureSpec.UNSPECIFIED); | |
| int h = View.MeasureSpec.makeMeasureSpec(0, | |
| View.MeasureSpec.UNSPECIFIED); | |
| imageView.measure(w, h); | |
| int height = imageView.getMeasuredHeight(); | |
| int width = imageView.getMeasuredWidth(); | |
| } |
| /* | |
| * Author: Felipe Herranz ([email protected]) | |
| * Contributors:Francesco Verheye ([email protected]) | |
| * Israel Dominguez ([email protected]) | |
| */ | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.concurrent.atomic.AtomicBoolean; | |
| import android.os.Handler; |