アンドロイドで日付ピッカーを表示するアプリを開発しています。問題は、フルスクリーンのdatepickerダイアログフラグメントを取得しようとしたときです。私はあなたが下の画像で見ることができる画面を取得します。より大きな日付ピッカーを得る方法はありますか?前もって感謝します!ここでAndroidでDatePickerを使用したフルスクリーンのDialogFragment
https://i.stack.imgur.com/gSj4F.png
が私のコードです:
DatePickerFragment.java
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
Dialog dialog = getDialog();
if (dialog != null)
{
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
dialog.getWindow().setLayout(width, height);
}
//Use the current date as the default date in the date picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
@Override
public void onStart()
{
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
{
//Fullscreen dialog
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
dialog.getWindow().setLayout(width, height);
}
}
public void onDateSet(DatePicker view, int year, int month, int day) {
//Do something with the date chosen by the user
TextView tvFecha = (TextView) getActivity().findViewById(R.id.tvFecha);
month = month+1;
String formattedMonth = "" + month;
String formattedDay = "" + day;
if(month < 10){
formattedMonth = "0" + month;
}
if(day < 10){
formattedDay = "0" + day;
}
String stringOfDate = formattedDay + "-" + formattedMonth + "-" + year;
tvFecha.setText(stringOfDate);
}
}