Я разрабатываю пользовательский диалог (используя DialogFragment), который запрашивает представление календаря, позволяющее пользователю выбирать дату. Диалоговое окно отображается, но «ОК» и «Отмена» видны только частично. Here is the screenshot for your reference.DialogFragment ~ частично видимые диалоговые кнопки
Вот мой заказ dialogfragment класс
public class GetDateDialogFragment extends DialogFragment implements android.content.DialogInterface.OnClickListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
LayoutInflater inflater = getActivity().getLayoutInflater();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View calendarView = inflater.inflate(R.layout.activity_datepicker, null);
calendarView.findViewById(R.id.btnOk).setVisibility(View.INVISIBLE);
calendarView.findViewById(R.id.btnCancel).setVisibility(View.INVISIBLE);
builder.setView(calendarView);
AlertDialog dialog = builder.setTitle(R.string.datetitle).setMessage("Please enter Date")
.setPositiveButton("OK", this).setNegativeButton("Cancel", null).create();
dialog.show();
dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, 600);
//position the buttons
//Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
//positiveButton.setY(positiveButton.getY()-100);
//Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
//negativeButton.setY(negativeButton.getY()-100);
return dialog;
}
Здесь Вы можете найти код для макета activity_datepicker.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="250dp"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical" />
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:layout_alignRight="@id/calendarView"
android:text="@string/btnOk" />
<Button
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/calendarView"
android:layout_alignParentBottom="true"
android:text="@string/btnCancel" />
Почему вы жестко обозначены как 600? –
Я попытался увеличить высоту, чтобы увидеть, помогает ли это, но независимо от того, увеличиваю или уменьшаю высоту, кнопки видны частично только – Hemant
, а затем покажите свой макет activity_datepicker. –