I am new to Android programming and I want to use an element DatePickerin my layout. I can use it successfully, but I cannot figure out how to change its selected date color. I read a lot of threads on this site and they talk about color changing in DatePickerDialog. I tried to follow similar approaches for an element DatePicker, but could not do it. I can change the date textColorusing the attribute calendarTextColor. My code for the layout file is as follows:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/datePicker"
android:datePickerMode="calendar"
android:spinnersShown="false"
android:layout_gravity="center"
android:layout_marginTop="-52dp"
android:layout_marginBottom="-20dp"
style="@style/MyDatePickerStyleTheme"
/>
</LinearLayout>
And here is the corresponding styles.xml code:
<style name="MyDatePickerStyleTheme" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="colorAccent"> #00ff00 </item>
<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
<item name="android:colorPrimary"> #00ff00 </item>
<item name="android:colorPrimaryDark"> #00ff00 </item>
<item name="android:colorAccent"> #00ff00 </item>
<item name="android:backgroundTint"> #00ff00 </item>
</style>
<style name="MyDatePickerStyle">
<item name="android:calendarTextColor"> #00ff00 </item>
</style>
Some additional points that I would like to add:
- Attribute
android:calendarTextColor , MyDatePickerStyleTheme, MydatePickerStyle.
, .- Android (Lollipop Marshmallow) .
- , .
.