?textAppearanceLabelSmall
Login Or Sign up

How can I change Android spinner DatePicker text appearance?

54 Views Asked by At

It's style of my DatePicker:

<style name="AppDatePicker">
    <item name="android:textAppearance">?textAppearanceLabelSmall</item> <!-- This effects nothing. -->
    <item name="android:colorControlNormal">?colorPrimary</item>
</style>

It's my DatePicker:

<DatePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:calendarViewShown="false"
    android:datePickerMode="spinner"
    android:spinnersShown="true"
    android:theme="@style/AppDatePicker" />

How can I change spinner DatePicker's text appearance ?

1

There are 1 best solutions below

4
Dinh Lam On

Follow xml attrs here: https://developer.android.com/reference/android/widget/DatePicker#summary

We have:

android:dayOfWeekTextAppearance
android:headerMonthTextAppearance
... and more

These attrs are deprecated from sdk 28

Other solution, create theme for date picker and set CalendarStyle

<style name="MyDatePicker" parent="....">
        <item name="android:calendarViewStyle">@style/MyCalendar</item>

<!-- For spinner -->
<item name="android:textColorPrimary">@color/...</item>
<item name="fontFamily">...</item>
<item name="android:textSize">...</item>

</style>

<style name="MyCalendar" parent="...">
   <item name="android:dateTextAppearance">Your text appearance</item>
</style>

use it

 <DatePicker
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/MyDatePicker" .../>