내장 안드로이드 시계 앱의 Day Picker에서 영감을 얻었습니다.
참고 : 저는이 라이브러리의 새로운 기능을 적극적으로 작업하지 않습니다. 나는 중요한 버그 만 다루고 있습니다. 새로운 기능에 대한 기여는 환영받는 것 이상이며 풀 요청을 검토 할 수 있습니다. 기여에 관심이 있으시면 Contributing.md를 참조하십시오.
| 정상적인 사용 | 현지화 된 사용 | 다크 모드 사용 |
|---|---|---|
![]() | ![]() | ![]() |
firstDayOfWeek 재산을 사용하여 피커에 표시된 주 1 주를 수동으로 재정의 할 수 있습니다.버그 수정
3.6.1 을 사용할 때 버그를 수정하여 selectionMode 속성을 찾을 수 없기 때문에 건물이 실패하게됩니다.버그 수정
setSelectedDays 호출하면 선택된 일이 깜박일 수있는 문제를 해결합니다.구성 개선
app:selectionMode 속성을 사용하여 XML을 통해 선택 모드를 설정할 수 있습니다. 프로젝트의 build.gradle 파일에 다음을 추가하여 최신 버전을 다운로드하십시오.
dependencies {
implementation ' ca.antonious:materialdaypicker:0.7.4 '
}기존 XML에보기를 떨어 뜨릴 수 있습니다.
< ca .antonious.materialdaypicker.MaterialDayPicker
android : id = " @+id/day_picker "
android : layout_width = " match_parent "
android : layout_height = " wrap_content " />다음을 사용하여 현재 선택된 날을 얻을 수 있습니다.
val selectedDays = materialDayPicker.selectedDays
// returns [MaterialDayPicker.Weekday.TUESDAY, MaterialDayPicker.Weekday.FRIDAY]다음을 수행하여 선택한 날을 설정할 수 있습니다.
val daysToSelect = listOf ( MaterialDayPicker . Weekday . TUESDAY , MaterialDayPicker . Weekday . FRIDAY )
materialDayPicker.setSelectedDays(daysToSelect)한 번에 하루 만 선택되도록 허용하려면 다음을 수행 할 수 있습니다.
materialDayPicker.selectionMode = SingleSelectionMode .create() selectionMode 속성을 사용하여 XML을 통해 설정할 수도 있습니다.
< ca .antonious.materialdaypicker.MaterialDayPicker
...
app : selectionMode = " ca.antonious.materialdaypicker.SingleSelectionMode " />다음 방법을 사용하여 일을 활성화/비활성화 할 수 있습니다. 참고 선택한 날을 비활성화하면 선택 해제 할 수 없습니다.
materialDayPicker.enableDay( MaterialDayPicker . Weekday . Monday )
materialDayPicker.disableDay( MaterialDayPicker . Weekday . Monday )
materialDayPicker.setDayEnable( MaterialDayPicker . Weekday . Monday , isEnabled = false )하루 선택이 변경 될 때마다 듣고 싶다면 다음을 사용할 수 있습니다.
materialDayPicker.setDaySelectionChangedListener { selectedDays ->
// handle selection change
}특정 날이 언제 선택/제거되는시기를 알아야하는 경우 다음을 사용할 수 있습니다.
materialDayPicker.setDayPressedListener { weekday, isSelected ->
// handle weekday selection
}이러한 색상을 무시하여 MaterialDayPicker 모양을 변경할 수 있습니다. 또한 Night Color Resources 디렉토리에서 이러한 값을 업데이트하여 Dark Mode에서 MaterialDayPicker가 어떻게 보이는지 업데이트 할 수 있습니다.
< color name = " dayPressed " >@color/colorPrimaryDark</ color >
< color name = " daySelected " >@color/colorPrimary</ color >
< color name = " daySelectedTextColor " >@android:color/white</ color >
< color name = " dayDeselected " >#FAFAFA</ color >
< color name = " dayDeselectedTextColor " >@android:color/black</ color >
<!-- Customizing colors for disabled days -->
< color name = " daySelectedAndDisabled " >#43444F</ color >
< color name = " daySelectedAndDisabledTextColor " >@color/daySelectedTextColor</ color >
< color name = " dayDeselectedAndDisabled " >@color/dayDeselected</ color >
< color name = " dayDeselectedAndDisabledTextColor " >@android:color/darker_gray</ color >장치의 현재 로케일을 사용하지 않으려면 다음을 통해이를 재정의 할 수 있습니다.
materialDayPicker.locale = Locale . ENGLISH // or any other locale요일의 첫날을 명시 적으로 지정하려면 :
materialDayPicker.firstDayOfWeek = MaterialDayPicker . Weekday . MONDAY // or any other day MIT License
Copyright (c) 2017 George Antonious
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.