Hello,
How do I set the background color the title of the datepicker popup in android to my app primary color. also like to change the selected date color
You can create a styles.xml
, add custom android:datePickerDialogTheme
in it like following code. I add all of properties that can be changed in native android datePicker. You can choose some of them that you want.
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="MainTheme.Base">
<item name="android:datePickerDialogTheme">@style/CustomDatePickerDialog</item>
</style>
<style name="CustomDatePickerDialog" parent="ThemeOverlay.AppCompat.Dialog">
<!--header background-->
<item name="colorAccent">#009933</item>
<!--header textcolor-->
<item name="android:textColorPrimaryInverse">#ff9900</item>
<!--body background-->
<item name="android:windowBackground">#000099</item>
<!--selected day-->
<item name="android:colorControlActivated">#ff8000</item>
<!--days of the month-->
<item name="android:textColorPrimary">#ffff00</item>
<!--days of the week-->
<item name="android:textColorSecondary">#ff0066</item>
<!--cancel&ok-->
<item name="android:textColor">#00ffff</item>
</style>
</resources>
Then, you can set this Theme
to your MainActivity. But this action will affect MAUI splash screen in android, if you want to use splash screen, you can refer to this document: splash-screen to create a new one.
[Activity(Theme = "@style/MyTheme", ....)]
public class MainActivity : MauiAppCompatActivity
{
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.