diff --git a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java index c684644..14b5d7d 100644 --- a/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java +++ b/app/src/main/java/com/github/florent37/sample/singledateandtimepicker/SingleDatePickerMainActivityWithDoublePicker.java @@ -18,6 +18,8 @@ import java.util.concurrent.TimeUnit; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.res.ResourcesCompat; + import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -214,8 +216,8 @@ public void onClosed(SingleDateAndTimePicker picker) { Log.d(TAG, "Dialog closed"); } }) - .title("Simple") + .titleTypeFace(ResourcesCompat.getFont(getBaseContext(), R.font.dinot_bold)) .listener(new SingleDateAndTimePickerDialog.Listener() { @Override public void onDateSelected(Date date) { diff --git a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java index 7307e62..5b17f32 100644 --- a/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java +++ b/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/dialog/SingleDateAndTimePickerDialog.java @@ -1,6 +1,7 @@ package com.github.florent37.singledateandtimepicker.dialog; import android.content.Context; +import android.graphics.Typeface; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -33,6 +34,8 @@ public class SingleDateAndTimePickerDialog extends BaseDialog { @Nullable private Integer titleTextSize; @Nullable + private Typeface titleTypeFace; + @Nullable private Integer bottomSheetHeight; @Nullable private String todayText; @@ -128,6 +131,10 @@ public void onClick(View v) { if (titleTextSize != null) { titleTextView.setTextSize(titleTextSize); } + + if (titleTypeFace != null) { + titleTextView.setTypeface(titleTypeFace); + } } picker.setTodayText(new DateWithLabel(todayText, new Date())); @@ -215,6 +222,11 @@ public SingleDateAndTimePickerDialog setTitleTextSize(@Nullable Integer titleTex return this; } + public SingleDateAndTimePickerDialog setTitleTypeFace(@Nullable Typeface titleTypeFace) { + this.titleTypeFace = titleTypeFace; + return this; + } + public SingleDateAndTimePickerDialog setBottomSheetHeight(@Nullable Integer bottomSheetHeight) { this.bottomSheetHeight = bottomSheetHeight; return this; @@ -352,6 +364,9 @@ public static class Builder { @Nullable private Integer titleTextSize; + @Nullable + private Typeface titleTypeFace; + @Nullable private Integer bottomSheetHeight; @@ -416,6 +431,11 @@ public Builder titleTextSize(@Nullable Integer titleTextSize) { return this; } + public Builder titleTypeFace(@Nullable Typeface titleTypeface) { + this.titleTypeFace = titleTypeface; + return this; + } + public Builder bottomSheetHeight(@Nullable Integer bottomSheetHeight) { this.bottomSheetHeight = bottomSheetHeight; return this; @@ -549,6 +569,7 @@ public Builder focusable() { public SingleDateAndTimePickerDialog build() { final SingleDateAndTimePickerDialog dialog = new SingleDateAndTimePickerDialog(context, bottomSheet) .setTitle(title) + .setTitleTypeFace(titleTypeFace) .setTitleTextSize(titleTextSize) .setBottomSheetHeight(bottomSheetHeight) .setTodayText(todayText)