Android 5.0 DatePicker with Theme.AppCompat

I am trying to create a material design application for previous versions of Android using Theme.AppCompat. I want to show lollipop DatePicker in this previous version, but now my DatePicker App on Android 4 devices looks like this .

The code:

Dialog call:

DatePickerDialog dialog = new DatePickerDialog(getActivity(),
                            new mDateSetListener(), mYear, mMonth, mDay);
                    dialog.show();

DatePicker Class:

 @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }

    class mDateSetListener implements DatePickerDialog.OnDateSetListener {

        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
            int mYear = year;
            int mMonth = monthOfYear;
            int mDay = dayOfMonth;
            /*System.out.println(mYear);
            System.out.println(mMonth);
            System.out.println(mDay);*/


        }
    }

Is it possible to show DatePicker Material Design Date in previous versions as I want?

thank.

+4
source share
2 answers

DatePicker Material Design pre-lollipop - , , ​​ .

+4

, , lib , , (Oreo, 8.0) DatePickerDialog TimePickerDialog appcompat API 14+.

lib , jCenter gradle:

compile 'com.takisoft.fix:datetimepicker:1.0.0'
+1

Source: https://habr.com/ru/post/1569431/


All Articles