开发者

android: layout: How to make my dialog box fill the screen with the XML

I'm trying to get a Dialog box to open covering most the screen (by that I mean it still has its nice rounded effect but cover the content behind)

I've been trying with fill parent but it keeps behaving like a wrap content

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http开发者_如何学Go://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>

I tried the solution here

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

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

and it does what I want

so now I want to know what is worng in my xml (I try to put all layout behavior inside the xml rather than in my code if I can help it ^^)


As I understand it the issue that the solution to How can I get a Dialog style activity window to fill the screen? solved was that the layout had to be modified after the xml had been loaded. Basically there is no xml that can do this alone.


Set a Transparent(glass.png)image as the background of the parent linearlayout of your xml. The dialog will cover 90% of your screen. You can find the required image glass.png by searching in google images.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜