有人遇到过这个问题吗?
这是DatePickerFragment的实现:
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { public static DatePickerFragment newInstance(int day,int month,int year) { DatePickerFragment frag = new DatePickerFragment(); Bundle args = new Bundle(); args.putInt("day",day); args.putInt("month",month); args.putInt("year",year); frag.setArguments(args); return frag; } @OverrIDe public Dialog onCreateDialog(Bundle savedInstanceState) { int year = getArguments().getInt("year"); int month = getArguments().getInt("month"); int day = getArguments().getInt("day"); DatePickerDialog datePickerDialog =new DatePickerDialog(getActivity(),this,year,month,day); datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000); return datePickerDialog; } @OverrIDe public voID onDateSet(DatePicker vIEw,int year,int monthOfYear,int dayOfMonth) { try { DatePickerDialogListener Listener = (DatePickerDialogListener)getActivity(); Listener.onFinishDatePickDialog(year,monthOfYear + 1,dayOfMonth); } catch (Exception ex) { ex.printstacktrace(); } } // 1. defines the Listener interface with a method passing back data result. public interface DatePickerDialogListener { voID onFinishDatePickDialog(int year,int dayOfMonth); }}
这里是样式表,它有一个androID的组件:datePickerDialogtheme
<style name="Apptheme.NoActionbar" parent="theme.AppCompat.light.NoActionbar"> <item name="androID:windowContentTransitions">true</item> <item name="colorControlnormal">@color/colorAccent</item> <item name="colorControlActivated">@color/colorAccent</item> <item name="colorControlHighlight">@color/colorAccent</item> <item name="textcolorError">@androID:color/holo_red_dark</item> <item name="androID:timePickerDialogtheme">@style/AlertDialogCustom</item> <item name="androID:datePickerDialogtheme">@style/AlertDialogCustom</item> <item name="androID:alertDialogtheme">@style/AlertDialogCustom</item> </style> <style name="AlertDialogCustom" parent="androID:theme.Material.light.Dialog.Alert"> <item name="androID:colorPrimary">@color/colorPrimary</item> <item name="androID:colorAccent">@color/colorAccent</item> </style>
注意:如果我不使用样式来修改颜色,则不会出现此问题.
解决方法 不要使用theme.AppCompat.light.Dialog.Alert,只需使用theme.AppCompat.light.Dialog即可.当你看里面时,< style name =“Base.themeOverlay.AppCompat.Dialog.Alert”>
< item name =“androID:windowMinWIDthMajor”> @ dIEm / abc_dialog_min_wIDth_major< / item>
< item name =“andorID:windowMinWIDthMinor”> @ dimen / abc_dialog_min_wIDth_minor< / item>
< /风格>
风格有额外的尺寸修改,结果是不受欢迎的.
总结以上是内存溢出为你收集整理的如何在DatePickerDialog中删除多余的空间(在Android M&N上看到)?全部内容,希望文章能够帮你解决如何在DatePickerDialog中删除多余的空间(在Android M&N上看到)?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)