How to change the style of a DatePicker in android?
Try this. It's the easiest & most efficient way
<style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary</item>
</style>
Change date-picker text color in spinner mode in android?
You can use:
<DatePicker
android:theme="@style/MyDatePicker"
..>
with:
<style name="MyDatePicker" >
<!-- Text color -->
<item name="android:textColorPrimary">@color/....</item>
<!-- Divider color -->
<item name="colorControlNormal">@color/...</item>
</style>
Change Date picker dialog theme
try as below
Button btn_ok = alert.getButton(DialogInterface.BUTTON_POSITIVE);
btn_ok .setBackgroundColor(Color.YELLOW); //add your color
Change fontcolor of DatePicker Android
EDIT2: This works. (Added divider color)
Your XML
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/datePicker"
android:calendarViewShown="false"
android:spinnersShown="true"
android:datePickerMode="spinner"
android:layout_below="@+id/tb_register_last_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/bt_register_tostep3"
android:layout_alignEnd="@+id/bt_register_tostep3"
android:theme="@style/MyDatePicker"/>
In styles.xml, set this (copy-paste the code)
<style name="MyDatePicker" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorControlNormal">#00FF00</item>
<item name="colorControlActivated">#00FF00</item>
<item name="android:textColorPrimary">#FF0000</item>
</style>
Google materialdoc will be helpful for you in the future.
Change your style and let me know if it works!!
How to change the style from DatePicker and TimePicker programmatically in Android?
I've found my own answer and it is quite simple. When instaciating the TimePicker and DatePicker send as parameter a new ContextThemeWrapper with the custom style you want in order to change the style.
Style.xml
<style name="CustomPickerTheme">
<item name="colorAccent">@color/Red</item>
</style>
MainActivity.class
TimePicker timePicker = new TimePicker(new ContextThemeWrapper(MainActivity.this, R.style.CustomPickerTheme));
DatePicker datePicker = new DatePicker(new ContextThemeWrapper(MainActivity.this, R.style.CustomPickerTheme));
Related Topics
Firebase Cloud Messaging Send Click_Action
How to Draw Border on Just One Side of a Linear Layout
How to Center Progress Indicator in Progressdialog Easily (When No Title/Text Passed Along)
Java.Lang.Noclassdeffounderror: Android.Support.V7.Appcompat.R$Styleable
Why the View Keeps Flashing When Using Jetpack Navigation with Compose
Get the Touch Position Inside the Imageview in Android
Error 12501 Authenticating with Google Sign-In
Android Recyclerview Findviewholderforadapterposition Returns Null
Get Nfc Tag with Ndef Android Application Record (Aar)
Error: Failed to Resolve: Com.Android.Support:Appcompat-V7:29.0.1'
How to Kill Sub Activities and Bring Activity to Top of Stack
Android How to Replace the Deprecated Tabhost
How to Get App Install Time from Android
How to Import Eclipse Project to Android Studio
Adb Got Two Same Serial Numbers When Connected to Two Smart Phones