Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize style Theme.Holo.Light.Dialog.MinWidth for DatePicker

I am using datePicker to input a date.

<style name="DatePickerTheme" parent="@android:style/Theme.Holo.Light.Dialog.MinWidth">
    <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
    <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
</style>

and in Activity.java

public void showDatePickerDialog(View v) {
        DialogFragment newFragment = new Login.DatePickerFragment();
        newFragment.show(getSupportFragmentManager(), "datePicker");
    }

    public static class DatePickerFragment extends DialogFragment
            implements DatePickerDialog.OnDateSetListener {

        @NonNull
        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            return new DatePickerDialog(getActivity(), R.style.DatePickerTheme, this, 1995, 0, 1);
        }

        public void onDateSet(DatePicker view, int year, int month, int day){                
                    dateSelected = year+"-"+month+"-"+day;

        }
    }

Issue is that I am getting a background tile, which I dont want.

I am getting this

but I want

the edited one

like image 327
impossible Avatar asked Feb 05 '23 18:02

impossible


1 Answers

This line can help:

datePickerDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
like image 172
Tamashii Avatar answered Feb 07 '23 12:02

Tamashii