标题翻译
DatePickerDialog leaves white space android
问题
我有一个日期选择对话框,每当对话框打开时,它都会显示如图所示的白色空白区域(在日期选择器的右侧)。
我尝试过设置布局参数:
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);
但仍然不起作用。有什么建议吗?
英文翻译
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??
答案1
得分: 0
这里最好的适应方法是在您的代码中使用缩放。
<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>
试试这段代码,希望能对您有所帮助。
英文翻译
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
答案2
得分: 0
尝试在此处将宽度设置为MATCH_PARENT。
ViewGroup.LayoutParams.WRAP_CONTENT,
更改为:
ViewGroup.LayoutParams.MATCH_PARENT,
更新后的回答:
日期选择对话框的尺寸似乎与您的视图不匹配。
尝试像这样设置对话框的尺寸:
datepikerdialog.getWindow().setLayout(width,height)
英文翻译
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)
专注分享java语言的经验与见解,让所有开发者获益!
评论