1

Is it possible to change default color of the TimePickerAndroid component ?

enter image description here

void42
  • 921
  • 2
  • 10
  • 14

2 Answers2

15

You would have to change it from the styles.xml file of android. Here's what you do:

1) Open up styles.xml: "android/app/src/main/res/values/styles.xml" 2) you'll need to add a few lines:

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <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>

In styles.xml you should already have:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

If you do just add the remaining lines. If not go ahead and add them.

4) Lastly, just recompile the app. "react-native run-android". You should see the color change right away.

Jophy Johnson
  • 473
  • 5
  • 9
1

Using React-native, unfortunately no.

However, by changing some java files in RN and using this solution from SO you might be able to do it. If you succeed doing this, I suggest you create a Pull Request on RN's repository as it might be very useful for other users. You could also develop it as a module and open source via NPM.

Community
  • 1
  • 1
G. Hamaide
  • 7,078
  • 2
  • 36
  • 57