android: layout: 如何让我的对话框用 XML 填满屏幕

标签 android layout fill-parent

我正在尝试让一个对话框打开,覆盖大部分屏幕(我的意思是它仍然具有漂亮的圆形效果,但覆盖了后面的内容)

我一直在尝试使用 fill parent 但它一直表现得像一个包装内容

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_centerHorizontal="true"
 >


<LinearLayout
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <SurfaceView android:id="@+id/surface"
        android:layout_width="400px"
        android:layout_height="200px"
        android:layout_centerHorizontal="true">
    </SurfaceView>
    <Button android:id="@+id/Button01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Ok, Let me play !!!" />
</LinearLayout>
</LinearLayout>

我在这里尝试了解决方案

How can I get a Dialog style activity window to fill the screen?

dialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

它做了我想要的

所以现在我想知道我的 xml 中有什么问题(如果可以的话,我尝试将所有布局行为放在 xml 中而不是我的代码中 ^^)

最佳答案

据我了解,How can I get a Dialog style activity window to fill the screen? 的解决方案解决的是布局必须在 加载 xml 之后进行修改。基本上没有可以单独完成此操作的 xml。

关于android: layout: 如何让我的对话框用 XML 填满屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5791942/

相关文章:

python - PyQt - 如何将单独的 UI 小部件添加到 QMainWindow

android - 通过 XML 设置 AdMob 横幅以匹配父级宽度

android - UnsatisfiedLinkError : n_Mat while using opencv2. 4.3 与 android 4.0

android - 订单已取消(Google 开发者控制台)

java - 通过循环为按钮分配 onClick 监听器 - Android

java - 向表格单元格 LibGDX 添加加号/减号按钮

css - 滚动内容溢出的 flexbox

android - TextView 高度不匹配_parent/fill_parent

android - 是否有任何可靠的方法来加密 Android 中的共享首选项(Min Api 19)