【问题标题】:android: layout: How to make my dialog box fill the screen with the XMLandroid: layout: 如何让我的对话框用 XML 填充屏幕
【发布时间】:2011-08-13 02:41:52
【问题描述】:

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

我一直在尝试使用填充父级,但它一直表现得像一个包装内容

<?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 中而不是我的代码中 ^^)

【问题讨论】:

    标签: android layout fill-parent


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      将透明(glass.png)图像设置为 xml 的父线性布局的背景。 该对话框将覆盖 90% 的屏幕。 您可以通过谷歌图片搜索找到所需的图片glass.png。

      【讨论】:

      • 嘿,你能帮我让它拉伸并填满整个屏幕,而不仅仅是 png 文件的像素大小吗?
      猜你喜欢
      • 2022-11-10
      • 2011-01-19
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多