How to change Android DatePicker Dialog's “Dividers” Colors

前端 未结 6 1420
無奈伤痛
無奈伤痛 2021-01-04 18:50

I\'m trying to create a custom dialog, basically I\'m using DatePickerDialog.THEME_HOLO_DARK but I want to change the \"divider\" color and the text color.

6条回答
  •  [愿得一人]
    2021-01-04 19:30

    Please use the below code

    Here, dialog is an object of DatePickerDialog.

        int dividerId = dialog.getContext().getResources().getIdentifier
                ("android:id/titleDivider", null, null);
        View divider = dialog.findViewById(dividerId);
        divider.setBackgroundColor(getResources().getColor(R.color.red));
    
        int textViewId = dialog.getContext().getResources().getIdentifier
                ("android:id/alertTitle", null, null);
        TextView tv = (TextView) dialog.findViewById(textViewId);
        tv.setTextColor(getResources().getColor(R.color.red));
    

提交回复
热议问题