我想改变timepicker对话框片段的默认颜色。 现在我不知道我应该做什么。如何更改默认颜色方案timepicker对话框片段?
这是我设法我的主题设置为(withouth的的动作条):
但这是对话框我得到:
这是我的XML样式文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/color_accent</item>
<item name="colorPrimaryDark">@color/color_secondary</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:statusBarColor">@color/color_primary</item>
</style>
</resources>
我的色彩文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="flat_text">#f14268</color>
<color name="background_flatbtn">#fff</color>
<color name="color_accent">#f14268</color>
<color name="color_primary">#d83b5d</color>
<color name="color_secondary">#d83b5d</color>
</resources>
mytimepicker片段:
public class DialogHandler extends DialogFragment
implements TimePickerDialog.OnTimeSetListener {
Context context;
public DialogHandler(Context context){
this.context=context;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
TimePickerDialog dialog= new TimePickerDialog(new ContextThemeWrapper(getActivity(),R.style.AppTheme), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
// Create a new instance of TimePickerDialog and return it
return dialog;
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Do something with the time chosen by the user
Toast.makeText(context, "your time is selected",Toast.LENGTH_LONG).show();
}
}
我对话的呼叫:
DialogHandler newFragment = new DialogHandler(getApplicationContext());
newFragment.show(getSupportFragmentManager() , "time_Picker");
请帮助我。 在此先感谢:)
可能重复【如何改变的DatePicker和TimePicker对话框中Android的默认颜色?](http://stackoverflow.com/questions/11077530/how-to-change-the-default-color-of-datepicker-and-timepicker-dialog-in-android) –