DatePickerDialog leaves white space android

Viewed 463

I have a date picker dialog ,there is a white space as shown in image

when ever dialog opens it shows the white space as shown in image(in right side of datePicker) ,

i tried setting layout Params

DatePickerDialog dialog = new DatePickerDialog(_context, this,
                _birthYear, _month,
                _day);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.getDatePicker().setLayoutParams(params);
        dialog.setCancelable(false);
        dialog.getDatePicker().setSpinnersShown(false);
        dialog.getDatePicker().setCalendarViewShown(true);

still it aint working

any suggestions??

2 Answers

Here is the best way to fit this is to use scale in your code.

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">
            <DatePicker
                android:id="@+id/datePicker"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="37dp"
                android:scaleX="1.2"
                android:scaleY="1.2"/>
</LinearLayout>

Try out this code I hope that will help you

Try to set the width to MATCH_PARENT over here.

ViewGroup.LayoutParams.WRAP_CONTENT, 

TO:

ViewGroup.LayoutParams.MATCH_PARENT, 

Updated ans:

There seems to be a size mismatch with the datepicker dialog and your view.

Try setting the size of the dialog like this:

datepikerdialog.getWindow().setLayout(width,height)
Related