有一个背景的DatePicker [英] DatePicker having a background
本文介绍了有一个背景的DatePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题是,具有日期选择器背后的一个丑陋的白色背景我的日期选择器
我只是想这样的背景下,以消失
这是我的code
公共无效selectDate(查看视图){
DialogFragment newFragment =新SelectDateFragment();
newFragment.show(Master_.fragmentManager的DatePicker);
}公共无效populateSetDate(INT年,月整型,诠释天){
Birthdate.setText(年+ - +月+ - +天);}公共类SelectDateFragment扩展DialogFragment工具
DatePickerDialog.OnDateSetListener {
@覆盖
公共对话框onCreateDialog(捆绑savedInstanceState){
最终日历日历= Calendar.getInstance();
INT YY = calendar.get(Calendar.YEAR);
INT毫米= calendar.get(的Calendar.MONTH);
INT DD = calendar.get(Calendar.DAY_OF_MONTH); DatePickerDialog对话框=新DatePickerDialog(mActivity,R.style.jehadStyle,为此,YY,MM,DD);
。dialog.getDatePicker()setMaxDate(calendar.getTimeInMillis()); 返回对话框;
} 公共无效onDateSet(查看的DatePicker,诠释YY,INT毫米,诠释DD){
populateSetDate(YY的MM + 1,DD);
}
}
这就是我的风格。
<样式名称=jehadStyle父=@安卓风格/ Theme.Holo.Light.Dialog.NoActionBar>
<项目名称=机器人:文字颜色> @android:彩色/黑白LT; /项目>< /风格>
解决方案
dialog.getWindow()setBackgroundDrawable(新ColorDrawable(Color.TRANSPARENT))。
添加到您的DatePickerDialog
the problem is that my date picker having an ugly White background behind the date picker
i just want that background to Disappear
this is My code
public void selectDate(View view) {
DialogFragment newFragment = new SelectDateFragment();
newFragment.show(Master_.fragmentManager, "DatePicker");
}
public void populateSetDate(int year, int month, int day) {
Birthdate.setText(year + "-" + month + "-" + day);
}
public class SelectDateFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar calendar = Calendar.getInstance();
int yy = calendar.get(Calendar.YEAR);
int mm = calendar.get(Calendar.MONTH);
int dd = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog =new DatePickerDialog(mActivity,R.style.jehadStyle, this, yy, mm, dd);
dialog.getDatePicker().setMaxDate(calendar.getTimeInMillis());
return dialog ;
}
public void onDateSet(DatePicker view, int yy, int mm, int dd) {
populateSetDate(yy, mm + 1, dd);
}
}
and this is my style
<style name="jehadStyle" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
<item name="android:textColor">@android:color/black</item>
</style>
解决方案
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
add this to your DatePickerDialog
这篇关于有一个背景的DatePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文