中文 | English
⭐🎉一个高颜值日期时间选择器;极简API,内置弹窗,支持农历日期显示,简单适配深色模式,可动态配置样式及主题,选择器支持完全自定义UI。
加载不出图片可以前往 掘金 查看
或者 点击下载
Step 1. 添加 JitPack repository
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. 添加 Gradle依赖
dependencies {
...
implementation 'com.google.android.material:material:1.1.0' //为了防止不必要的依赖冲突,0.0.3开始需要自行依赖google material库
implementation 'com.github.loper7:DateTimePicker:0.6.3'//具体版本请看顶部jitpack标识,如0.6.3,仅支持androidx
}
日期时间选择控件
DateTimePicker 使用说明
卡片弹窗
CardDatePickerDialog 使用说明
自定义选择器
DateTimePicker 自定义
周选择弹窗
CardWeekPickerDialog 使用说明
/**
* 设置dialog选中日期信息展示格式
* @param value 1:LUNAR 0:DEFAULT
* @return Builder
*/
fun setChooseDateModel(value: Int): Builder {
this.chooseDateModel = value
return this
}
//由于背景、DateTimePicker以及主题色均可由开发者灵活配置,为了兼容这些配置,所以适配深色模式需要调用以下几个方法进行设置。
//1.自定义dialog背景,为light/dark模式设置不同的值 builder.setBackGroundModel(if(isDark) R.drawable.shape_bg_dialog_dark else R.drawable.shape_bg_dialog_light) //2.自定义dialog辅助文字颜色 .setAssistColor(if(isDark) darkColor else lightColor) //3.自定义dialog分割线颜色 .setDividerColor(if(isDark) darkColor else lightColor)
//这样深色模式就适配完成了,当然,以上三个方法的作用不仅可以用于适配深色模式,也可以传入更契合app主题的颜色,用于与app统一UI风格。
### [v0.5.7](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.7) -> [v0.5.8](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.8)
* fix [issues 57](https://github.com/loperSeven/DateTimePicker/issues/57)
### [v0.5.3](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.3) -> [v0.5.7](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.7)
* fix [issues 51](https://github.com/loperSeven/DateTimePicker/issues/51)
* fix [issues 53](https://github.com/loperSeven/DateTimePicker/issues/53)
### [v0.5.2](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.2) -> [v0.5.3](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.3)
* fix [issues 47](https://github.com/loperSeven/DateTimePicker/issues/47)
* fix [issues 48](https://github.com/loperSeven/DateTimePicker/issues/48)
### [v0.5.1](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.1) -> [v0.5.2](https://github.com/loperSeven/DateTimePicker/releases/tag/0.5.2)
* fix [issues 44](https://github.com/loperSeven/DateTimePicker/issues/44)
* `CardDatePickerDialog` 支持设置 `touchHideable`, 用以控制是否允许滑动手势关闭弹窗
```kotlin
/**
* 是否可以滑动关闭弹窗
* @param touchHideable 默认为 true
*/
fun setTouchHideable(touchHideable:Boolean = true):Builder{
this.touchHideable = touchHideable
return this
}
CardWeekPickerDialog
支持设置 formatter
,可自定义格式化展示样式
/**
* 设置格式化
* @param datas 数据
* @return Builder
*/
fun setFormatter(formatter: (MutableList<MutableList<Long>>) -> NumberPicker.Formatter?): Builder {
this.formatter = formatter
return this
}
var lunar = Lunar.getInstance(calendar)
lunar?.apply {
Log.d("lunar",lunar.toString())
}
CardDatePickerDialog
内原标题下日期信息变更为农历日期信息支持设置国际化日期选择格式
DateTimePicker
新增如下方法,CardDatePickerDialog
不受任何影响。
/**
* 设置国际化日期格式显示 如果没有自定义layout且需要设置的日期格式为 dd-MM(单词缩写)-yyyy HH:mm:ss,此方法会改变年月日的顺序,及月份的显示。
* @param global : DateTimeConfig.GLOBAL_LOCAL 根据设备系统语言自动选择
* DateTimeConfig.GLOBAL_CHINA 设置日期格式为 yyyy-MM-dd HH:mm:ss
* DateTimeConfig.GLOBAL_US 设置日期格式为 dd-MM(单词缩写)-yyyy HH:mm:ss
*/
fun setGlobal(global: Int) {
...
}
/**
* 获取类型对应的NumberPicker
* @param displayType 类型
*/
fun getPicker(displayType: Int): NumberPicker? {
...
}
-dontwarn com.loper7.date_time_picker.**
-keep class com.loper7.date_time_picker.**{*;}
Issues:Issues
邮箱:loper7@163.com
Copyright 2020 loperSeven
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.