Tambosi
Tambosi

Reputation: 31

Android: How to change DatePickerDialog colors in Theme.Holo.Light.Dialog.MinWidth?

I'm using Api 14 and the only way i found to hide the calendar view from my DataPickerDialog is using Theme.Holo.Light.Dialog.MinWidth when I create it. But now i'm not able to change the colors of text and header.

Image of DatePickerDialog

How to change the blue color and the ok/cancel buttons?

Code of styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/backtext</item>
    <!-- Customize your theme here. -->
</style>
<style name="DatePickerTheme" parent="@android:style/Theme.Holo.Light.Dialog.MinWidth">
    <item name="colorAccent">@color/border</item>
    <item name="android:headerBackground">@color/border</item>
    <item name="android:textColorHighlight">@color/backtext</item>
</style>

DatePickerDialog creation code:

    private void InitDatePicker() {
            Calendar newCalendar = Calendar.getInstance();
            //android.R.style.Theme_Holo_Dialog_MinWidth
            //

            datePickerDialog = new DatePickerDialog(this, R.style.DatePickerTheme,new DatePickerDialog.OnDateSetListener() {
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar newDate = Calendar.getInstance();
                    newDate.set(year, monthOfYear, dayOfMonth);
                    dtVenc.setText(new SimpleDateFormat().format(newDate.getTime()));
                }
            }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
            HideDayButton(datePickerDialog.getDatePicker());
            datePickerDialog.setTitle("Vencimento");
}

Upvotes: 3

Views: 4259

Answers (3)

Muhaiminur Rahman
Muhaiminur Rahman

Reputation: 3152

You can try this way

<style name="abirStyle" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:background">@null</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>

Upvotes: 1

Muhaiminur Rahman
Muhaiminur Rahman

Reputation: 3152

You can try this way

<style name="abirStyle" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
    <item name="android:textColor">@color/colorPrimary</item>
    <item name="android:background">@null</item>
    <item name="android:textColorPrimary">@color/colorPrimary</item>
</style>

Upvotes: 1

Vivek Pratap Singh
Vivek Pratap Singh

Reputation: 1662

try this

you should use headerBackground instead android:headerBackground and same for android:textColorHighlight remove android

this should work

Upvotes: 4

Related Questions