public void applyStyle(int resId){ mYearPicker.applyStyle(resId); mDatePicker.applyStyle(resId); mHeaderPrimaryColor = mDatePicker.getSelectionColor(); mHeaderSecondaryColor = mHeaderPrimaryColor; Context context = getContext(); TypedArray a = context.obtainStyledAttributes(resId, R.styleable.DatePickerDialog); for(int i = 0, count = a.getIndexCount(); i < count; i++){ int attr = a.getIndex(i); if(attr == R.styleable.DatePickerDialog_dp_headerPrimaryHeight) mHeaderPrimaryHeight = a.getDimensionPixelSize(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_headerSecondaryHeight) mHeaderSecondaryHeight = a.getDimensionPixelSize(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_headerPrimaryColor) mHeaderPrimaryColor = a.getColor(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_headerSecondaryColor) mHeaderSecondaryColor = a.getColor(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_headerPrimaryTextSize) mHeaderPrimaryTextSize = a.getDimensionPixelSize(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_headerSecondaryTextSize) mHeaderSecondaryTextSize = a.getDimensionPixelSize(attr, 0); else if(attr == R.styleable.DatePickerDialog_dp_textHeaderColor) mTextHeaderColor = a.getColor(attr, 0); } a.recycle(); mPaint.setTypeface(mDatePicker.getTypeface()); }