Android library for easy selection of date range on selection bar. Date range could be selected by scrolling or clicking on the date range shown next to focused one.
implementation 'com.github.banmarkovic:DateRangeSelectionBar:0.1.3'
app:drsTextSize="16sp"
app:drsTextColor="@android:color/white"
app:drsUnderlineColor="@android:color/white"
app:drsVerticalPadding="14dp"
For receiving the dates of selected date range in selection bar, you need to pass instance of
DateRangeSelectionBar.DRSOnTimePeriodSelectListener interface in DateRangeSelectionBar view.
private val onTimePeriodSelectListener = object: DateRangeSelectionBar.DRSOnTimePeriodSelectListener {
override fun onDatePeriodSelected(datePeriod: DRSDatePeriod) {
Toast.makeText(this@MainActivity, "${datePeriod.startDate} - ${datePeriod.endDate}", Toast.LENGTH_SHORT).show()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
dateRangeSelectionBar.setCurrentShownTimePeriodType(DRSDatePeriodType.DRSMonthlyType)
dateRangeSelectionBar.onTimePeriodSelectListener = onTimePeriodSelectListener
dateRangeSelectionBar.allowFutureDates = true
}
Change the date period type shown in selection bar (default is DRSDatePeriodType.DRSMonthlyType).
Set DateRangeSelectionBar.DRSOnTimePeriodSelectListener listener.
Enable showing of future dates (default is true).
DRSDatePeriodType.DRSDailyType //Days
DRSDatePeriodType.DRSWeeklyType //Weeks
DRSDatePeriodType.DRSMonthlyType //Months
DRSDatePeriodType.DRSYearlyType //Years