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

时间:2011-04-26 14:36:21

标签: android layout 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中的worng是什么(我尝试将所有布局行为放在xml中,而不是在我的代码中,如果我可以帮助它^^)

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

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