but the button colors are not coming on UI. What is the solution and correct way to implement date picker theme according to application.
CodePudding user response:
Modify your theme.xml something like this -
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/light_yellow</item>
<item name="android:colorAccent">@color/light_yellow</item>
<item name="android:buttonBarPositiveButtonStyle">@style/DialogButtonStyled</item>
<item name="android:buttonBarNegativeButtonStyle">@style/DialogButtonStyled</item>
<item name="android:buttonBarNeutralButtonStyle">@style/DialogButtonStyled</item>
</style>
<style name="DialogButtonStyled" parent="Theme.MaterialComponents.Light">
<item name="android:textColor">@color/black</item>
</style>
CodePudding user response:
Add this in your style.xml file
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/yourColor</item>
</style>
And then add this style while creating the DatePickerDialog
DatePickerDialog datePicker = new DatePickerDialog(context, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
}