Android gets the control in DatePicker through reflection and changes its color. androiddatepicker
In the end, the color of the middle part is successfully changed.
Private void setDatePickerDividerColor (DatePicker datePicker) {// Divider changing: // get mSpinners LinearLayout llFirst = (LinearLayout) datePicker. getChildAt (0); // obtain NumberPicker LinearLayout mSpinners = (LinearLayout) llFirst. getChildAt (0); for (int I = 0; I <mSpinners. getChildCount (); I ++) {NumberPicker picker = (NumberPicker) mSpinners. getChildAt (I); Field [] pickerFields = NumberPicker. class. getDeclaredFields (); for (Field pf: pickerFields) {pf. setAccessible (true); String pfString = pf. getName (); try {if (pfString. equals ("mSelectionDivider") {pf. set (picker, new ColorDrawable (Color. parseColor ("# ffffff"); // sets the split line color break;} else if (pfString. equals ("mInputText") {EditText mInputText = (EditText) pf. get (picker); // obtain the mInputText object corresponding to this attribute. setTextColor (view. getResources (). getColor (R. color. white); break;} else if (pfString. equals ("mSelectorWheelPaint") {Paint mPaint = (Paint) pf. get (picker); // obtain the object mPaint corresponding to this attribute. setColor (view. getResources (). getColor (R. color. white); break;} else if (pfString. equals ("mVirtualButtonPressedDrawable") {pf. set (picker, new ColorDrawable (Color. parseColor ("# ffffff"); break ;}} catch (IllegalArgumentException e) {e. printStackTrace ();} catch (Resources. notFoundException e) {e. printStackTrace ();} catch (IllegalAccessException e) {e. printStackTrace ();}}}}