@@ -15,7 +15,7 @@ repositories {
15
15
}
16
16
17
17
dependencies {
18
- compile 'com.chaos.view:pinview:1.1 .0'
18
+ compile 'com.chaos.view:pinview:1.2 .0'
19
19
}
20
20
```
21
21
@@ -30,20 +30,22 @@ Add PinView in your layout.
30
30
``` xml
31
31
<com .chaos.view.PinView
32
32
android : id =" @+id/pinView"
33
+ style =" @style/PinWidget.PinView"
33
34
android : layout_width =" wrap_content"
34
35
android : layout_height =" wrap_content"
35
- android : inputType = " number "
36
- android : padding = " 5dp "
37
- android : text = " 12345 "
36
+ android : hint = " Hint. "
37
+ android : inputType = " text "
38
+ android : padding = " @dimen/common_padding "
38
39
android : textColor =" @color/text_colors"
39
40
android : textSize =" 18sp"
40
- app : borderColor =" @color/border_colors"
41
- app : borderWidth =" 2dp"
42
41
app : itemCount =" 5"
43
- app : itemSize =" 48dp"
44
- app : itemSpacing =" 4dp"
42
+ app : itemHeight =" 48dp"
45
43
app : itemRadius =" 4dp"
46
- style =" @style/PinWidget.PinView" />
44
+ app : itemSpacing =" 0dp"
45
+ app : itemWidth =" 36dp"
46
+ app : lineColor =" @color/line_colors"
47
+ app : lineWidth =" 2dp"
48
+ app : viewType =" rectangle" />
47
49
```
48
50
49
51
#### Java
@@ -53,16 +55,17 @@ PinView pinView = (PinView) findViewById(R.id.secondPinView);
53
55
pinView. setTextColor(
54
56
ResourcesCompat . getColor(getResources(), R . color. colorAccent, getTheme()));
55
57
pinView. setTextColor(
56
- ResourcesCompat . getColorStateList(getResources(), R . color. text_colors , getTheme()));
57
- pinView. setBorderColor (
58
+ ResourcesCompat . getColorStateList(getResources(), R . color. line_colors , getTheme()));
59
+ pinView. setLineColor (
58
60
ResourcesCompat . getColor(getResources(), R . color. colorPrimary, getTheme()));
59
- pinView. setBorderColor(
60
- ResourcesCompat . getColorStateList(getResources(), R . color. border_colors, getTheme()));
61
- pinView. setItemCount(5 );
62
- pinView. setItemSize(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_box_height));
63
- pinView. setItemRadius(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_box_radius));
64
- pinView. setItemSpacing(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_box_margin));
65
- pinView. setBorderWidth(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_box_border_width));
61
+ pinView. setLineColor(
62
+ ResourcesCompat . getColorStateList(getResources(), R . color. text_colors, getTheme()));
63
+ pinView. setItemCount(4 );
64
+ pinView. setItemHeight(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_item_size));
65
+ pinView. setItemWidth(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_item_size));
66
+ pinView. setItemRadius(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_item_radius));
67
+ pinView. setItemSpacing(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_item_spacing));
68
+ pinView. setLineWidth(getResources(). getDimensionPixelSize(R . dimen. pv_pin_view_item_line_width));
66
69
pinView. setAnimationEnable(true );// start animation when adding text
67
70
```
68
71
@@ -77,7 +80,7 @@ Specifies `pinViewStyle` in your theme,
77
80
</style >
78
81
```
79
82
80
- or implement ` PinWidget.PinView ` style.
83
+ or use the ` PinWidget.PinView ` style.
81
84
82
85
``` xml
83
86
<com .chaos.view.PinView
@@ -87,6 +90,19 @@ or implement `PinWidget.PinView` style.
87
90
style =" @style/PinWidget.PinView" />
88
91
```
89
92
93
+ ## Attributes
94
+
95
+ * ** itemSize** , @deprecated use itemWidth or itemHeight instead.
96
+ * ** borderWidth** , @deprecated use lineWidth instead.
97
+ * ** borderColor** , @deprecated use lineColor instead.
98
+ * ** itemCount** , the length of your pin code.
99
+ * ** itemWidth** , the width of each item.
100
+ * ** itemHeight** , the height of each item.
101
+ * ** itemSpacing** , the spacing between two items.
102
+ * ** lineWidth** , the line(border) width.
103
+ * ** lineColor** , the line(border) colors.
104
+ * ** viewType** , the view type of PinView, currently this will be one of ` rectangle ` or ` line ` .
105
+
90
106
## Thanks
91
107
92
108
* Inspired by [ PasswordInput] ( https://github.com/EthanCo/PasswordInput ) in [ EthanCo] ( https://github.com/EthanCo )
0 commit comments