Android 我的对话框现在填充整个高度,而不是环绕内容
我试图使用一个对话框窗口,人们可以在其中填写一些信息。但我遇到了一个问题,它在高度(而不是宽度)上填满了我的整个屏幕。 这是我的布局文件:Android 我的对话框现在填充整个高度,而不是环绕内容,android,xml,Android,Xml,我试图使用一个对话框窗口,人们可以在其中填写一些信息。但我遇到了一个问题,它在高度(而不是宽度)上填满了我的整个屏幕。 这是我的布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/t
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/dialog_bg"
tools:context=".UI.Main.Create.CreateStoryDialogFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//some fields
</LinearLayout>
</RelativeLayout>
有人可能会说我哪里出了问题吗?使用
android:layout\u height=“wrap\u content”
如果您想按内容包装视图,那么如果您在布局XML中替换所有android:layout\u height=“match\u parent”
,它应该可以工作
您可能需要使用
FrameLayout
替换RelativeLayout
尝试将linearlayout中的android:layout\u height=“match\u parent”更改为android:layout\u height=“wrap\u content”。如果能成功的话。
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));