3

I have this layout:

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <DatePicker
        style="@style/MyDatePickerStyle"
        android:id="@+id/datePicker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dip"
        android:layout_marginRight="5dip"
        android:calendarViewShown="false"
        android:calendarTextColor="@color/Black"
        android:headerDayOfMonthTextAppearance="@color/accent_color"
        android:background="@color/gray_light_date"
        android:headerBackground="@color/app_bar_color"
        android:dayOfWeekBackground="@color/app_bar_color"
        android:dayOfWeekTextAppearance="@color/Black"
        />
</LinearLayout>

Style used by the layout:

<style name="MyDatePickerStyle" parent="@android:style/Widget.Holo.DatePicker">
    <item name="android:headerBackground">@color/ColorPrimary</item>
    <item name="android:calendarTextColor">@color/ColorPrimaryDark</item>
    <item name="android:dayOfWeekBackground">@color/ColorPrimaryDark</item>
    <item name="android:yearListSelectorColor">@color/accent_color</item>
    <item name="android:datePickerMode">calendar</item>
</style>

You can see the screen generated by this layout below:

enter image description here

I want to change the text color of those month days.

It's currently white and I want to change it instead of the background.

I search on the google and tried a lot of different attributes and styles, but I have no success.

Can you help-me?

Thanks.

leonvian
  • 4,719
  • 2
  • 26
  • 31

1 Answers1

0

You have to change font color for datePicker widget in Android native?
Then you have to implement below of code that will help you.

DatePicker picker;
ViewGroup childpicker;

childpicker = (ViewGroup) findViewById(Resources.getSystem().getIdentifier("month" /*rest is: day, year*/,    "id", "android"));
EditText textview = (EditText) picker.findViewById(Resources.getSystem().getIdentifier("timepicker_input", "id",  "android"));
textview.setTextColor(Color.GREEN);

OR in Style

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.SelectDate" parent=" <at> android:style/Theme.Holo.NoActionBar">
    <item name="android:editTextStyle"> <at> style/Widget.EditText.Black</item>
</style>

<style name="Widget.EditText.Black" parent=" <at> android:style/Widget.EditText">
    <item name="android:textColor"> <at> color/black</item>
</style>
Stefano Sansone
  • 2,377
  • 7
  • 20
  • 39
Ravi Vaghela
  • 3,420
  • 2
  • 23
  • 51