Open manideepla opened 4 years ago
Can somebody help with this please?
In xml use
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
android:id="@+id/calendar_view_range"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mcv_selectionMode="range"
/>
In xml use
<com.prolificinteractive.materialcalendarview.MaterialCalendarView android:id="@+id/calendar_view_range" android:layout_width="match_parent" android:layout_height="wrap_content" app:mcv_selectionMode="range" />
That just allows me to select a range of dates. What I wanted is something like this:
If you just want basic highlighting (without the handles and rounded corners), it is easy.
drawable/bg_selected_date
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/primaryLightColor"/>
</shape>
drawable/sl_bg_selected_date
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_selected_date" android:state_checked="true" />
<item android:drawable="@android:color/transparent" />
</selector>
class SelectionDecorator(private val selectionDrawable: Drawable): DayViewDecorator {
override fun shouldDecorate(day: CalendarDay?) = true
override fun decorate(view: DayViewFacade?) {
view?.setSelectionDrawable(selectionDrawable)
}
}
calendar.addDecorator(SelectionDecorator(
context.getDrawable(R.drawable.sl_bg_selected_date)
?: throw Exception("No selection drawable")
))
Now selected range appears as below:
Hello Aditya Bhaskar, Thank you for your code snippet using it i am able to succeed to fulfil my need as well, But as you can see the screen shot attached i want corners as mentioned in screenshot, So can you please give some suggestion or guide me that how can i achieve as shown in this screenshot
@yugmewada This library is abandonware. It has had no updates for 6 years. Besides, Google now provides first party date pickers in Compose. I'd suggest just using those.
Like how Google's Material Date Picker shows?