5
5
import android .graphics .drawable .Drawable ;
6
6
import android .view .View ;
7
7
8
+ import androidx .annotation .ColorInt ;
8
9
import androidx .annotation .NonNull ;
9
10
import androidx .recyclerview .widget .RecyclerView ;
10
11
11
12
/**
12
13
* An extension of {@link RecyclerView.ItemDecoration} that
13
- * – when applied to a {@link RecyclerView} –
14
- * draws a horizontal divider at the bottom of each item in the {@link RecyclerView}.
14
+ * draws a divider between each item in a {@link RecyclerView}.
15
15
* <p>
16
- * This class is a modification of N J's answer on Stack Overflow <a href="http://stackoverflow.com/a/31243174/1071320">here</a>.
16
+ * Unlike the {@link androidx.recyclerview.widget.DividerItemDecoration} class offered by the
17
+ * <a href="https://maven.google.com/web/index.html#androidx.recyclerview:recyclerview">recyclerview</a>
18
+ * library, this class does not draw the divider under the final item in the {@link RecyclerView}.
19
+ * <p>
20
+ * See <a href="https://stackoverflow.com/a/27037230/1071320">this answer</a> in Stack Overflow
21
+ * for a better understanding of {@link RecyclerView.ItemDecoration}.
17
22
*/
18
- public class HorizontalDividerItemDecoration extends RecyclerView .ItemDecoration {
23
+ public class RecyclerViewDividerItemDecoration extends RecyclerView .ItemDecoration {
19
24
20
25
private final Drawable dividerDrawable ;
21
26
private final int dividerHeightPixels ;
@@ -25,15 +30,15 @@ public class HorizontalDividerItemDecoration extends RecyclerView.ItemDecoration
25
30
/**
26
31
* Constructor.
27
32
*
28
- * @param dividerColor the color value to apply to the divider.
29
- * @param dividerHeightPixels the height to apply to the divider (in pixels).
30
- * @param dividerMarginLeftPixels the size of the left margin (in pixels).
31
- * @param dividerMarginRightPixels the size of the right margin (in pixels).
33
+ * @param dividerColor The color to apply to the divider.
34
+ * @param dividerHeightPixels The height to apply to the divider (in pixels).
35
+ * @param dividerMarginLeftPixels The left margin to apply to the divider (in pixels).
36
+ * @param dividerMarginRightPixels The right margin to apply to the divider (in pixels).
32
37
*/
33
- public HorizontalDividerItemDecoration ( int dividerColor ,
34
- int dividerHeightPixels ,
35
- int dividerMarginLeftPixels ,
36
- int dividerMarginRightPixels ) {
38
+ public RecyclerViewDividerItemDecoration ( @ ColorInt int dividerColor ,
39
+ int dividerHeightPixels ,
40
+ int dividerMarginLeftPixels ,
41
+ int dividerMarginRightPixels ) {
37
42
this .dividerDrawable = new ColorDrawable (dividerColor );
38
43
this .dividerHeightPixels = dividerHeightPixels ;
39
44
this .dividerMarginLeftPixels = dividerMarginLeftPixels ;
0 commit comments