我創建了TimePickerDialog並更改了默認顏色。另外,我想將風格改變成不同的風格。TimePickerDialog與舊款式和不同顏色
我找不到方法來改變顏色,也風格的同時。
這是我創造了我TimePickerDialog:
TimePickerDialog代碼:
public void showHourPicker() {
final Calendar myCalender = Calendar.getInstance();
int hour = myCalender.get(Calendar.HOUR_OF_DAY);
int minute = myCalender.get(Calendar.MINUTE);
TimePickerDialog.OnTimeSetListener myTimeListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
if (view.isShown()) {
myCalender.set(Calendar.HOUR_OF_DAY, hourOfDay);
myCalender.set(Calendar.MINUTE, minute);
updateHourEditText(myCalender);
}
}
};
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(),R.style.TimePickerDialogStyle , myTimeListener, hour, minute, true);
timePickerDialog.setTitle("Choose hour:");
timePickerDialog.show();
}
這它的樣式:
<style name="TimePickerDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorControlActivated">@color/mcgpalette_300</item>
<item name="colorAccent">@color/mcgpalette_300</item>
</style>
如果我嘗試更改樣式,如下圖所示,我得到了我想要的樣式,但沒有像上面的示例那樣使用顏色。 代碼良好的作風,但沒有我的顏色:
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), 2 , myTimeListener, hour, minute, true);
我的問題是:如何設置樣式是在第二張圖片和顏色,在第一張照片?
'amPmTextColor'不影響微調模式,並在API 21中引入。 –