Search code examples
xamarin.formscolorstimepicker

How to change TimePicker Theme color?


I have this code to change the theme of the datepicker in my app in styles file in android project:

<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#039BE5</item>
  </style>

Is there a code same to this that can help me for the timepicker?


Solution

  • You can define style in style.xml

    <style name="TimePickerTheme" parent="Theme.AppCompat.Light.Dialog">
     <item name="colorAccent">#039BE5</item>
     <item name="android:layout_width">wrap_content</item>
     <item name="android:layout_height">wrap_content</item>
    </style>
    

    And

    TimePickerDialog timePicker = new TimePickerDialog(mContext, Resource.style.TimePickerTheme, fromListener, hour, min, false);