DatePicker having a background

此生再无相见时 提交于 2019-12-05 18:16:15

问题


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>

回答1:


dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

add this to your DatePickerDialog




回答2:


try like this,

<style name="jehadStyle" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
        <item name="android:textColor">@android:color/black</item>
        <item name="android:background">@null</item>
    </style>

hope it will help you




回答3:


dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

use with DatePickerDialog




回答4:


Try with this

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

add this line above "return dialog".



来源:https://stackoverflow.com/questions/27101906/datepicker-having-a-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!