Styling DatePicker Android Marshmallow -
i'm struggling android calendar styling. turns out android 6 ignores calendartextcolor , uses textcolorprimary in order style day labels textcolorsecondary style day of weeks. i've checked calendartextcolor on android 5 , works correctly. according documentation textcolorprimary used toolbar text color. https://developer.android.com/training/material/theme.html toolbar text color white , receive white day labels on white background. how specify calendartextcolor without touching textcolorprimary android api 23?
you make custom theme datepicker , specify text color there
try this
<style name="datepickertheme" parent="theme.appcompat.light.dialog"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="coloraccent">@color/colorprimary</item> <item name="android:textcolorprimary">@color/colorblack</item> <item name="android:textcolorsecondary">@color/colorblack</item> <item name="android:textcolortertiary">@color/colorblack</item> </style>
and can specify theme when call datepickerdialog this
final datepickerdialog.ondatesetlistener date = new datepickerdialog.ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // todo auto-generated method stub mycalendar.set(calendar.year, year); mycalendar.set(calendar.month, monthofyear); mycalendar.set(calendar.day_of_month, dayofmonth); string myformat = "mm/dd/yy"; //in need put here simpledateformat sdf = new simpledateformat(myformat, locale.us); calendar.settext(sdf.format(mycalendar.gettime())); } }; calendar.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub new datepickerdialog(youractivity.this,r.style.datepickertheme, date, mycalendar .get(calendar.year), mycalendar.get(calendar.month), mycalendar.get(calendar.day_of_month)).show(); } }); }
Comments
Post a Comment