Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable date input method inside google material date picker

"i'm using google's material date picker 'com.google.android.material:material:1.1.0-alpha10' version,and i want to disable the input method through keyboard,is there a way to disable/hide the edit method"

like image 318
milton titus Avatar asked Sep 09 '19 13:09

milton titus


1 Answers

you can use custom style as workaround to disable calendar input mode toggle. This toggle uses style attribute materialCalendarHeaderToggleButton, so:

<style name="Widget.AppTheme.MaterialDatePicker" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="materialCalendarHeaderToggleButton">@style/Widget.AppTheme.MaterialCalendar.HeaderToggleButton</item>
<style name="Widget.AppTheme.MaterialCalendar.HeaderToggleButton" parent="Widget.MaterialComponents.MaterialCalendar.HeaderToggleButton">
<item name="android:visibility">gone</item>

And after that apply theme with:

MaterialDatePicker.Builder.dateRangePicker()
    .setTheme(R.style.Widget_AppTheme_MaterialDatePicker)
like image 95
Sikander Bakht Avatar answered Sep 18 '22 02:09

Sikander Bakht