I need my TimePicker font color to be white. I tried approach, described in this question, but it doesn't work for me. So any ideas how can I do this?
Asked
Active
Viewed 3,227 times
0
-
http://stackoverflow.com/questions/10969513/how-can-i-override-timepicker-to-change-text-color – keshav Jan 10 '14 at 13:59
-
http://custom-android-dn.blogspot.fr/2013/03/how-to-create-custom-date-time-picker.html – keshav Jan 10 '14 at 14:00
-
http://stackoverflow.com/questions/10969513/how-can-i-override-timepicker-to-change-text-color – Bilal Rabbani Jun 22 '14 at 19:03
2 Answers
2
Create a style :
<style name="MyBase.TimePicker" parent="Theme.AppCompat.Light.Dialog">
<item name="android:background">@android:color/black</item>
<item name="android:headerBackground">@android:color/black</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:colorAccent">@android:color/white</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
Then use it in yout TimePicker like this :
<TimePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tpScheduleTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:theme="@style/MyBase.TimePicker"
android:timePickerMode="spinner" />

RedHac
- 31
- 4
0
You can add style like this:
<style name="TimePickerTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
and add this in your code:
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(),R.style.TimePickerTheme, (TimePickerDialog.OnTimeSetListener) getActivity(), hour, minute, android.text.format.DateFormat.is24HourFormat(getActivity()));

Mohammad Davari
- 430
- 3
- 13