Custom date picker Android - Kotlin - android

I'm trying to create a custom calendar in Android. I want to create somethning like this
custom calendar.
As you can see the design is slightly different than normal date picker for android. I tried to change it in xml, but like I found out, it isnt possible. So my question is - how to do that? Should I create custom class which extend from DatePicker? I was trying to find the solution by myself, but I found only answers to change color etc, but I want to also change design and font.
I will be very grateful for your help

Related

Custom date selector in android

I want to implement date selector like this in my app but I don't know how to do it I have searched a lot but couldn't find any solution
enter image description here
I tried different libraries but can not achieve the exact output

Is it possible to switch the format of date picker header?

I am trying to change the header on material design date picker as you select a date to a different format than default. Current default is Month , year : ex: june 22, 2021, but I want it such that its Mon, June 22. It's shown on material design document as the first design, but there's no indication of how to go about changing this format?
Any ideas?
material designs : https://material.io/components/date-pickers
what I want to achieve is this :
Unfortunately, you can NOT change Date Format and Local of MaterialDatePicker.
Since MaterialDatePicker is very restricting, so as many other Material Design Components, I recommend you to use an alternate Date Picker Library such as MaterialDateTimePicker.
It basically fulfills all your needs:
Change date format: setLocale(Locale locale) ✅
Choose from multiple date UIs ✅
Very flexiable and easily customizlbe to fit your needs ✅
PS: There is one more popular alternative: android-betterpickers
Let me know if you have any other questions.
After looking into the source, and trying some things, I did find a solution. Unfortunately, it's not that simple to implement and I guess switching to MaterialDateTimePicker is still the best solution here.
The conversion from date to text for the header is done by the DateSelector via getSelectionDisplayString(Context context). See getHeaderText() inside of MaterialDatePicker here.
Sadly, MaterialDatePicker is final, so you can not simply create your own and override this method. But, with the given Builder, you can use MaterialDatePicker.Builder.customDatePicker(DateSelector selector) to place your own DateSelector (source).
Material uses their SingleDateSelector (source) for a simple date selection. But again, it's not possible to build upon this selector and write a custom getSelectionDisplayString method, because the class is restricted. Knowing this, it's needed to write your own DateSelector.
Building your own DateSelector is a bigger task on its own. It may be possible to copy from SingleDateSelector, but it's using some private classes and methods you need to copy, too.
To cut a long story short, I guess this is too much for "simply" changing the date format.

Is it possible to add a dot below day on Android Material Datepicker?

I would like to add dots below specific dates, anyone knows if it's possible with the Material Components?
It's a similar problem to the one here - it does not seem to be currently supported by the MaterialDatePicker.
Feature request submitted here, feel free to back it up.
Update
The feature has been implemented and it's now possible to add a dot below days in the Material DatePicker. The material catalog has a very clear example of such an implementation.
You need to extend the DayViewDecorator class and override one of the getCompoundDrawable methods to create the drawable (little circle under each desired date) - in this case it would be getCompoundDrawableBottom.

Custom CalendarView

I want to display a CalendarView and then change backgound of certain blocks (of dates) red and certain blocks green. Now, I don't think I can do that in default CalendarView.
So, I started googling about how to create a custom CalendarView and I came to know that creating a custom CalendarView is impossible. We have to use a GridView.
So, I just wanted to know that is that really true and if it is not then how should I go about making a custom CalendarView
There is a library available now known as ZCustomCalendar which allows you to define individual custom views for various types of dates.

Android: advanced ColorPickerDialog

I'm looking for an advanced Android color picker dialog. The standard color picker from the API Demos and examples from this post aren't quite acceptable to me. I'd like it to look like this: this image. Are there any open source color pickers that look like that?
UPDATE: My primary goal is to make the Color Picker easy to use: it'd be great if the user only needs to click once to pick any color, and all possible colors are represented. The Color Pickers from the examples I've mentioned require two clicks to pick a color and are too complicated for the average user.
This one looks pretty close to what you want, and is FOSS:
https://github.com/LarsWerkman/HoloColorPicker
how about this solution ?
look at the screenshot:
source code here .
Have you tried Android Color Picker?
If you need to show the RGB-Code of the currently selected color, just modify the dialog by adding an TextView and adding an update to it in the ColorChangeListener (or whatever it's called)
Or take a look at the color-picker dialog of CyanogenMod
Here a link to the source: CyanogenMod color-picker on GitHub

Categories

Resources