Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change the default theme color #106

Closed
ugendrang opened this issue Oct 29, 2017 · 16 comments
Closed

How to change the default theme color #106

ugendrang opened this issue Oct 29, 2017 · 16 comments

Comments

@ugendrang
Copy link

Currently the datetime picker displays title background, date/time selection color and Footer text(Cancel, Ok) color with green color.

Is it possible to change the default theme color?

@mmazzarolo
Copy link
Owner

Hey @ugendrang , please take a look at #29

@ugendrang
Copy link
Author

ugendrang commented Nov 28, 2017

Thank you @mmazzarolo, its working after below changes in 'styles.xml'

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    item name="android:datePickerDialogTheme">@style/Dialog.Theme</item>
    <item name="android:timePickerDialogTheme">@style/Dialog.Theme</item>
</style>

<style name="Dialog.Theme" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF0000</item>
    <item name="android:textColorPrimary">#0000FF</item>
</style>

@SirPhemmiey
Copy link

@ugendrang you missed an opening tag over there. :-)

@kurniawanj26
Copy link

@ugendrang where can I find the styles.xml ?

@madeeha96
Copy link

It's always showing blue theme. How ever i use "#FFA500" i.e. orange
how can i use this color?

@ChenhuaWANG22
Copy link

ChenhuaWANG22 commented Dec 25, 2018

@mmazzarolo Is it possible to change color with using Expo ? Or we have to eject the project in order to change the color ?

I have read issue #29, issue #106 and some other related thread, edit all styles.xml file in my project folder and even create an android directory tree with styles.xml in it.
After hours trying, I'm still stuck with the color problem.
So please shed some light on this.

@mmazzarolo
Copy link
Owner

I don't think it's available in Expo yet: expo/expo#313

@paolospag
Copy link

paolospag commented Apr 3, 2019

Hi @mmazzarolo
this code:

<style name="Dialog.Theme" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF0000</item>
    <item name="android:textColorPrimary">#0000FF</item>
</style>

doesn't work for me with react-native 0.58.6 and react-native-modal-datetime-picker 6.1.0.

Schermata 2019-04-03 alle 15 09 55
colors seem to remain the Android default ones

Any workaround?

@mmazzarolo
Copy link
Owner

mmazzarolo commented Apr 4, 2019

ciao @paolospag !

No idea honestly, have you already tried checking in the React-Native issues? 🤔

Maybe this issue might be helpful?

@paolospag
Copy link

ciao @mmazzarolo 😄
sorry for the late response.

This code:

<style name="SpinnerDatePickerDialog" parent="android:Theme.Material.Light.Dialog">
    <item name="android:datePickerStyle">@style/MyDatePicker</item>
    <item name="android:colorAccent">@color/colorPrimary</item>
    <item name="android:colorControlNormal">@color/colorPrimary</item>
</style>

<style name="MyDatePicker" parent="android:Widget.Material.DatePicker">
    <item name="android:datePickerMode">spinner</item>
</style>

has definitely solved my problem, thank you so much!

@spidi123q
Copy link

Its not working for me! any other ways

@ivgraai
Copy link

ivgraai commented Jul 16, 2020

@ChenhuaWANG22 Try to change primarycolor in Expo.

@animeclover
Copy link

I try the below blog for adding datePickerAndroid and it's working fine also provide when a user has multiple input field for date solution.

https://infinitbility.com/how-to-add-datepickerandroid-in-react-native-with-color-changes

@rakesh-201
Copy link

Is there any way to change the theme of date picker in an expo managed react native app ?

@muheet9
Copy link

muheet9 commented Sep 15, 2022

@ugendrang where can I find the styles.xml ?

You can find the styles.xml file inside your android/app/src/main/res/values

High5Apps added a commit to High5Apps/organize-rn that referenced this issue Nov 8, 2023
- Needed to set the styles.xml colorAccent in order to affecting the picker theme accent color on Android
  - Initial advice from: mmazzarolo/react-native-modal-datetime-picker#106 (comment)
  - Actual solution inspired by: xamarin/Xamarin.Forms#9033 (comment)
@olarcher
Copy link

@rakesh-201 This is now possible with Expo config plugins, see https://stackoverflow.com/q/77703362/4350421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests