android - 我的对话框现在填充了整个高度,而不是环绕内容
问题描述
我正在尝试使用一个对话窗口,人们可以在其中填写一些信息。但我遇到的问题是它的高度(而不是宽度)填满了我的整个屏幕。
这是我的布局文件:
<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>
我在 DialogFragment 中使用了这一行:
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
有人可以说我哪里出错了吗?
解决方案
如果android:layout_height="wrap_content"
您想通过其内容包装视图,则使用它,如果您替换android:layout_height="match_parent"
布局 XML 中的所有内容,它应该可以工作。
您可能需要将 替换RelativeLayout
为FrameLayout
.
推荐阅读
- regex - Unix 正则表达式仅列出具有有效版本名称的目录
- azure - Terraform 计划在错误地声称它们不存在的数据元素上失败
- python - 如何将文件中的差异写入 Python 中的新文件?
- url-routing - 部署 Svelte Sapper 导出后路由不起作用
- datetime-format - 如果我的日期时间字符串中间有一个字母 I 是什么意思?
- google-apps-script - 获取具有特定值的单元格集合 Google 表格
- swift - Where do a UITableView's section footers get their width?
- r - How can I remove NAs when both columns are missing only?
- python - how to unnest a pandas column that its a string
- javascript - Permission denied for file upload in PHP