From 7196296fc3ec7800942fb0402aa48ca3e07f3177 Mon Sep 17 00:00:00 2001 From: raul Date: Fri, 2 Mar 2018 14:08:33 +0100 Subject: [PATCH] header color --- .../materialdatetimepicker/time/TimePickerDialog.java | 8 +++++++- .../datetimepickerexample/TimePickerFragment.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/wdullaer/materialdatetimepicker/time/TimePickerDialog.java b/library/src/main/java/com/wdullaer/materialdatetimepicker/time/TimePickerDialog.java index c32346e1..f331f200 100644 --- a/library/src/main/java/com/wdullaer/materialdatetimepicker/time/TimePickerDialog.java +++ b/library/src/main/java/com/wdullaer/materialdatetimepicker/time/TimePickerDialog.java @@ -28,6 +28,7 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -135,6 +136,7 @@ public enum Version { private boolean mThemeDarkChanged; private boolean mVibrate; private int mAccentColor = -1; + private int mHeaderColor = -1; private boolean mDismissOnPause; private Timepoint[] mSelectableTimes; private Timepoint mMinTime; @@ -248,6 +250,10 @@ public void setAccentColor(String color) { mAccentColor = Color.parseColor(color); } + public void setHeaderColor(@ColorInt int color) { + mHeaderColor = Color.argb(255, Color.red(color), Color.green(color), Color.blue(color)); + } + /** * Set the accent color of this dialog * @param color the accent color you want @@ -860,7 +866,7 @@ else if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) { } // Set the theme at the end so that the initialize()s above don't counteract the theme. - timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor)); + timePickerHeader.setBackgroundColor(Utils.darkenColor(mHeaderColor)); view.findViewById(R.id.mdtp_time_display_background).setBackgroundColor(mAccentColor); view.findViewById(R.id.mdtp_time_display).setBackgroundColor(mAccentColor); diff --git a/sample/src/main/java/com/wdullaer/datetimepickerexample/TimePickerFragment.java b/sample/src/main/java/com/wdullaer/datetimepickerexample/TimePickerFragment.java index 230fa5cb..a51cbf6f 100644 --- a/sample/src/main/java/com/wdullaer/datetimepickerexample/TimePickerFragment.java +++ b/sample/src/main/java/com/wdullaer/datetimepickerexample/TimePickerFragment.java @@ -79,6 +79,7 @@ public void onClick(View v) { if (limitSelectableTimes.isChecked()) { tpd.setTimeInterval(3, 5, 10); } + tpd.setHeaderColor(getResources().getColor(android.R.color.black)); tpd.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) {