У меня есть AlertDialog
, на который я установил пользовательский вид. В макете просмотре Android Studio, это показывает, что я ожидаю макет выглядеть следующим образом:Удалите лишнее пространство из AlertDialog
Однако, когда приложение работает на моем Nexus 6P это выглядит следующим образом (обратите внимание на дополнительное пространство в верхней части, то есть что Я не хочу):
As suggested here Я попытался изменить как макет был установлен:
alertDialog2.setView(view2,0,0,0,0);
alertDialog2.show();
Однако это не решило мою проблему. Любые предложения о том, как это сделать?
XML Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:text="Suggest improvements or changes, or report bugs."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:id="@+id/textView5"
android:textColor="@color/Black"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp">
<EditText
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/email_feedback_text"
android:layout_marginLeft="125dp"
android:layout_width="250dp"
android:layout_alignParentBottom="false"
android:layout_marginRight="5dp" />
<TextView
android:text="E-mail*:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:id="@+id/textV5"
android:textColor="@color/Black"
android:layout_alignParentLeft="true"
android:layout_marginLeft="30dp" />
</RelativeLayout>
</RelativeLayout>
Java:
AlertDialog.Builder alertDialogBuilderComplete = new AlertDialog.Builder(
MainActivity.this);
alertDialogBuilderComplete.setCancelable(false);
alertDialogBuilderComplete.setTitle("Submit Feedback"); //Set the title of the box
alertDialogBuilderComplete.setMessage("");
alertDialogBuilderComplete.setNegativeButton("Submit",null);
alertDialogBuilderComplete.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel(); //when they click dismiss we will dismiss the box
}
});
alertDialog2 = alertDialogBuilderComplete.create(); //create the box
alertDialog2.setOnShowListener(new DialogInterface.OnShowListener(){
@Override
public void onShow(DialogInterface dialog) {
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
button.setOnClickListener(new View.OnClickListener() {
}
});
}
});
alertDialog2.setView(view2,0,0,0,0);
alertDialog2.show();
вы можете вставить ваш макет XML? – Maragues
Обновлено, чтобы включить xml-макет – ez4nick
@ ez4nick проверить ответ bro – W4R10CK