DatePickerDialog not working as expected

痴心易碎 提交于 2019-12-09 06:03:25

this might be the Theme you are using in your project. So use below theme in your style file

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="colorPrimary">@color/green_sheet</item>
   <item name="android:textAllCaps">false</item>     
</style>

Hope this will help you out.

Remove this from your style:

<item name="android:textColorPrimary">@color/white</item>

try to this it can show dialog as you want

   new DatePickerDialog(MainActivity.this, R.style.datepicker, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int month, int day) {

            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, month);
            calendar.set(Calendar.DAY_OF_MONTH, day);

        }
    }, year, month, day).show();

dialog style as you wish

  <style name="datepicker" parent="Theme.AppCompat.Light.Dialog">

    <item name="colorAccent">@color/red</item>
</style>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!