自定义主题未在Datepicker对话框中应用

时间:2013-05-21 00:49:36

标签: android datepicker themes

我正在创建一个我想要应用自定义主题的DatePickerDialog。它只应用部分自定义主题。我要求无标题 windowBackground为灰色,结果整个对话框(数字和月份除外)为橙色。我究竟做错了什么?这是我的自定义主题:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="GPSTheme" parent="android:style/Theme.Dialog">
        <item name="android:textColor">#000000</item>
        <item name="android:windowTitleStyle">@style/Theme.Sherlock.Light</item>
        <item name="android:background">@drawable/orange_gradient</item>
        <item name="android:windowBackground">@drawable/cool_gradient</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

这是我调用对话框的地方(来自片段内):

btnStartDate.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
            public void onDateSet(DatePicker view, int year,
                    int monthOfYear, int dayOfMonth) {
                if (DatesValid(true, year, monthOfYear, dayOfMonth)) {
                    StartDate.set(Calendar.YEAR, year);
                    StartDate.set(Calendar.MONTH, monthOfYear);
                    StartDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    SetTextDates();
                } else {
                    Toast.makeText(
                            getActivity(),
                            "Start Date cannot be greater than End Date",
                            Toast.LENGTH_SHORT).show();
                }
                GetDistanceTraveledForTime();
            }
        };
        DatePickerDialog d = new DatePickerDialog(getActivity(),
                R.style.GPSTheme, mDateSetListener,
                StartDate.get(Calendar.YEAR), StartDate
                        .get(Calendar.MONTH), StartDate
                        .get(Calendar.DAY_OF_MONTH));
        //DatePicker dp = d.getDatePicker();
        //LinearLayout l = (LinearLayout)dp.getChildAt(0);
        //l.setBackgroundColor(R.drawable.orange_gradient);
        d.setIcon(R.drawable.calendar_2_icon);
        d.show();
    }
});

我在这里查看:https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml表示Theme.Dialog的所有继承属性。

这是一个截图:

Screenshot of dialog

0 个答案:

没有答案