22
33一个基于自定义LayoutManager的PickerView,扩展自由度极高。
44
5- ![ ] ( files/gif_picker .gif)
5+ ![ gif_picker.gif ] ( https://i.loli.net/2020/09/07/RBNdOF64fsCuj5U .gif)
66
77## 导入依赖
88
@@ -69,7 +69,7 @@ recyclerView.addItemDecoration(PickerItemDecoration())
6969
7070### TextPickerView
7171
72- ![ ] ( files/gif_text_picker .gif)
72+ ![ gif_text_picker.gif ] ( https://i.loli.net/2020/09/07/pUMW5o4TKBGlY9R .gif)
7373
7474这个实现相对简单,就自定义了一个item layout为TextView的Adapter而已,再做了一点自定义属性的封装。
7575
@@ -122,7 +122,7 @@ textPickerView.setData(items)
122122
123123### DataPickerView和TimePickerView
124124
125- ![ ] ( files/gif_date_time_picker .gif)
125+ ![ gif_date_time_picker.gif ] ( https://i.loli.net/2020/09/07/vREh2qdQi1HpgYj .gif)
126126
127127#### 支持的属性和方法
128128
@@ -131,33 +131,33 @@ textPickerView.setData(items)
131131#### 如何使用
132132
133133``` xml
134- <me .simple.picker.datepicker.DatePickerView
135- android : id =" @+id/datePickerView"
136- android : layout_width =" match_parent"
137- android : layout_height =" wrap_content"
138- app : isLoop =" true"
139- app : layout_constraintStart_toStartOf =" parent"
140- app : layout_constraintTop_toTopOf =" parent"
141- app : scrollToEnd =" true" />
142-
143- <me .simple.picker.timepicker.TimePickerView
144- android : id =" @+id/timePickerView"
145- android : layout_width =" match_parent"
146- android : layout_height =" wrap_content"
147- android : layout_marginTop =" 30dp"
148- app : layout_constraintStart_toStartOf =" parent"
149- app : layout_constraintTop_toBottomOf =" @id/tvDate" />
134+ <me .simple.picker.datepicker.DatePickerView
135+ android : id =" @+id/datePickerView"
136+ android : layout_width =" match_parent"
137+ android : layout_height =" wrap_content"
138+ app : isLoop =" true"
139+ app : layout_constraintStart_toStartOf =" parent"
140+ app : layout_constraintTop_toTopOf =" parent"
141+ app : scrollToEnd =" true" />
142+
143+ <me .simple.picker.timepicker.TimePickerView
144+ android : id =" @+id/timePickerView"
145+ android : layout_width =" match_parent"
146+ android : layout_height =" wrap_content"
147+ android : layout_marginTop =" 30dp"
148+ app : layout_constraintStart_toStartOf =" parent"
149+ app : layout_constraintTop_toBottomOf =" @id/tvDate" />
150150```
151151
152152#### 监听选中
153153
154154``` kotlin
155- datePickerView.setOnDateSelectedListener { year, month, day ->
155+ datePickerView.setOnDateSelectedListener { year, month, day ->
156156 tvDate.text = " $year -$month -$day "
157- }
157+ }
158158
159- timePickerView.setOnTimeSelectedListener { hour, minute ->
159+ timePickerView.setOnTimeSelectedListener { hour, minute ->
160160 tvTime.text = " $hour :$minute "
161- }
161+ }
162162```
163163
0 commit comments