Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change textsize in datepicker?

The default textsize in datepicker is too big for my app. I've seen a way suggested to change it here, but fishing around for the textviews nested inside the datepicker class seems clunky and error prone.

Is there a better/cleaner way to do it?

like image 418
gcl1 Avatar asked Jul 30 '12 18:07

gcl1


1 Answers

Setting a theme to DatePicker layout and adding android:textSize to it works for me.

In your layout's xml add a DatePicker applying a theme as shown below -

<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
            android:theme="@style/NumberPickerStyle"
            android:datePickerMode="spinner"
            android:calendarViewShown="false"
            android:layout_gravity="center_horizontal"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>

and then define the NumberPickerStyle in styles.xml specifying android:textSize like this -

<style name="NumberPickerStyle">
        <item name="android:textSize">@dimen/number_picker_text_size</item>
</style>
like image 117
shubham1g5 Avatar answered Sep 28 '22 04:09

shubham1g5