Android 从AlertDialog中删除不必要的空间
我有一个Android 从AlertDialog中删除不必要的空间,android,android-view,android-alertdialog,Android,Android View,Android Alertdialog,我有一个警报对话框,我将自定义视图设置为该对话框。在Android Studio的布局预览中,它显示了我期望的布局: 但是,当应用程序在我的Nexus 6P上运行时,它看起来是这样的(注意顶部的额外空间,这是我不想要的): 我尝试将布局设置为: alertDialog2.setView(view2,0,0,0,0); alertDialog2.show(); 然而,这并没有解决我的问题。对如何实现这一点有什么建议吗 XML布局: <RelativeLayout xmlns:andro
警报对话框
,我将自定义视图设置为该对话框。在Android Studio的布局预览中,它显示了我期望的布局:
但是,当应用程序在我的Nexus 6P上运行时,它看起来是这样的(注意顶部的额外空间,这是我不想要的):
我尝试将布局设置为:
alertDialog2.setView(view2,0,0,0,0);
alertDialog2.show();
然而,这并没有解决我的问题。对如何实现这一点有什么建议吗
XML布局:
<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>
发布xml后,我看到了
android:layout\u marginTop=“20dp”
make itandroid:layout\u marginTop=“0dp”
发布xml后,我看到了
android:layout\u marginTop=“20dp”
让它成为android:layout\u marginTop=“0dp”
........
.......
........
.......
删除此行:
alertDialogBuilderComplete.setMessage("")
或将其更改为:
alertDialogBuilderComplete.setMessage(null)
删除此行:
alertDialogBuilderComplete.setMessage("")
或将其更改为:
alertDialogBuilderComplete.setMessage(null)
您可以粘贴您的xml布局吗?已更新以包含xmllayout@ez4nick查看答案,并粘贴如何构建对话框。它是DialogFragment还是仅仅是AlertDialog?请注意,如果是后者,它将无法经受方向更改。添加java代码PLZ可以粘贴xml布局吗?更新为包含xmllayout@ez4nick查看答案,并粘贴如何构建对话框。它是DialogFragment还是仅仅是AlertDialog?请注意,如果是后者,它将无法经受方向更改。请添加java代码plzTried,并解决与以前相同的问题。我指的是下面的空间提交反馈和建议改进你指的是哪一个额外的空间?以上是否提交反馈?或以上建议的改进…?尝试了相同的问题。我指的是下面的空间提交反馈和建议改进你指的是哪一个额外的空间?以上是否提交反馈?或以上建议改进….?您是否尝试过从顶部相对位置移除?是的。问题持续存在您是否尝试从顶部相对位置删除?是。这个问题一直存在,谢谢!那就行了!它工作得很好,但当我真的想有一个消息,仍然有一个差距下的消息。有办法把它去掉吗?谢谢!那就行了!它工作得很好,但当我真的想有一个消息,仍然有一个差距下的消息。有没有办法把它去掉?
alertDialogBuilderComplete.setMessage(null)