时间选择器:MaterialCalendarView控件使用

2023-05-28  本文已影响0人  古早味蛋糕

一、简介
这几天有一个界面需要选择时间的界面,以前都是用Android 自带日期选择器(DatePicker和DatePickerDialog),显示效果是滚动式,和正在做的APP风格不搭,主要想实现日历风格时间选择器,于是选择了 MaterialCalendarView。
MaterialCalendarView将Android CalendarView 的Material Design风格向后移植。其目标是拥有Material的视觉和使用效果,而不是完全依赖于平台的实现.
Github:https://github.com/prolificinteractive/material-calendarview
CalendarView的特性

Step 2. Add the dependency

   implementation 'com.github.prolificinteractive:material-calendarview:1.6.0'

2、布局

<com.prolificinteractive.materialcalendarview.
    MaterialCalendarView    
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/materialCalendarView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/CustomTextAppearance"
    app:mcv_showOtherDates="all"
    app:mcv_selectionColor="#0080FF"
    app:mcv_arrowColor="@color/white"
    app:mcv_dateTextAppearance="@dimen/text_size"
    app:mcv_weekDayTextAppearance="@dimen/text_size"
    app:mcv_headerTextAppearance="@dimen/text_size"
/>

mcv_dateTextAppearance、mcv_weekDayTextAppearance、mcv_headerTextAppearance
以上这三个属性调节不同区域字体大小貌似无效,具体字体大小在自定义样式中设置即可,但是不能去掉这三个属性否则有可能导致设置字体大小无效

上一篇 下一篇

猜你喜欢

热点阅读