
Question:
<a href="https://i.stack.imgur.com/UQZ0T.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/UQZ0T.png" data-original="https://i.stack.imgur.com/UQZ0T.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>
I am using date picker and I need to style it with different colors. All things are working fine except the selected date color. The thing is selected date color takes "android:textColorPrimaryInverse" as default which in my case is red , background of the dialog is white and the "android:colorControlHighlight" and "android:colorControlActivated" is also red.
This means the selected text color doesn't show.I need that to be shown as white but the issue is if I change"android:textColorPrimaryInverse" to white my title won't appear as the background is white.
here is my style file :
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/color_white</item>
<item name="android:textColorPrimaryInverse">@color/red</item>
<item name="android:textColorSecondaryInverse">@color/red</item>
<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
<item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
<item name="android:colorControlHighlight">@color/red</item>
<item name="android:colorControlActivated">@color/red</item>
</style>
and this is how I show my dialog
new DatePickerDialog(mActivity, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
//DO SOMETHING
}
}, 2015, 02, 26).show();
Answer1:Use;
<item name="android:textColorPrimaryInverse">@color/white</item>
<item name="android:colorControlActivated">@color/red</item>
Answer2:Try below code
<style name="CustomDatePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/accent</item>
<item name="android:datePickerStyle">@style/CustomDatePickerStyle</item>
<item name="android:colorAccent">@color/primDark</item>
</style>
<style name="CustomDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker">
<item name="android:headerBackground">@color/prim</item>
<item name="android:calendarTextColor">@color/primDark</item>
<item name="android:dayOfWeekBackground">@color/primDark</item>
<item name="android:yearListSelectorColor">@color/accent</item>
<item name="android:datePickerMode">calendar</item>
</style>
Answer3:What you need to deal with in your style is 'colorControlActivated' and 'selectableItemBackgroundBorderless' . Check the code snippet below:
<item name="colorControlActivated">#@color/Green</item>
<item name="android:selectableItemBackgroundBorderless">@color/LightPink</item>
Current date will be 'Green' and selected date will have a 'LightPink' boardering background