Reputation: 85
I've been trying for more than half an hour to change the default date picker color to a color I want, but I can't, I've searched on internet forums, but I can't find a solution that solves my problem.
This is my datepicker:
This is more or less the result I want to get:
I made the datepicker in xml, and I want it to stay in xml anyway
<DatePicker
android:id="@+id/date_picker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
android:layout_marginTop="20dp"
style="@style/RYZZE_DATE_PICKER"
android:layout_marginBottom="40dp"
android:layout_centerHorizontal="true"
android:calendarViewShown="false"/>
style:
<style name="RYZZE_DATE_PICKER">
<item name="android:textColorPrimary">#ff00ff</item>
<item name="android:colorControlNormal">#ff00ff</item>
<item name="colorAccent">#ff00ff</item>
</style>
Upvotes: 0
Views: 957
Reputation: 9073
You need to change style
to android:theme
in DatePicker
.
as following:
<DatePicker
android:id="@+id/date_picker"
android:theme="@style/RYZZE_DATE_PICKER"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:calendarViewShown="false"
android:datePickerMode="spinner"
/>
To change the horizontal bars color you need to change colorControlNormal
& to change date text color you need to change textColorPrimary
as following.
<style name="RYZZE_DATE_PICKER">
<item name="android:textColorPrimary">#00796B</item>
<item name="android:colorControlNormal">#FBC02D</item>
</style>
Following is the result:
Upvotes: 0
Reputation: 713
You can use this.
<DatePicker
android:id="@+id/date_picker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
android:layout_marginTop="20dp"
android:theme="@style/RYZZE_DATE_PICKER"
android:layout_marginBottom="40dp"
android:layout_centerHorizontal="true"
android:calendarViewShown="false"/>
Upvotes: 1