我使用的是 Api 14,我发现从我的 DataPickerDialog 中隐藏日历 View 的唯一方法是在创建它时使用 Theme.Holo.Light.Dialog.MinWidth。 但现在我无法更改文本和标题的颜色。
如何更改蓝色和确定/取消按钮?
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 创建代码:
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");
}
最佳答案
试试这个
您应该使用 headerBackground
而不是 android:headerBackground
并且对于 android:textColorHighlight
删除 android
也是如此
这应该可行
关于Android:如何更改 Theme.Holo.Light.Dialog.MinWidth 中的 DatePickerDialog 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33578846/