将背景应用于android对话框

时间:2010-10-12 09:52:47

标签: android

我正在尝试使用少量下拉框和背景图像在Android上创建一个基本的自定义dialoge视图。

我遇到的问题是,由于某种原因,它总是将对话框绘制得比必要的大,因此,背景图像不会覆盖整个对话框。

最好我给你看一张我的意思:

alt text

抱歉,这是与此视图相关的我的xml文件:

<ImageButton android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/closeButton"
    android:src="@drawable/close_dialogue" android:background="@null"
    android:layout_alignParentRight="true" android:layout_marginRight="10dip" android:layout_marginTop="10dip"></ImageButton>
<TextView android:layout_height="wrap_content"
    android:layout_width="wrap_content" android:id="@+id/nzbNameText"
    android:text="Nzb Title" android:layout_below="@+id/closeButton" android:layout_marginLeft="10dip" style="@style/BoldBlackStyle"></TextView>
<TextView android:layout_height="wrap_content"
    android:layout_below="@+id/nzbNameText" android:layout_width="wrap_content"
    android:text="Catagory" android:id="@+id/catagoryLabel"
    android:layout_marginTop="20dip" android:layout_marginLeft="10dip" android:textColor="@color/Black"></TextView>
<Spinner android:layout_height="wrap_content"
    android:layout_below="@+id/catagoryLabel" android:layout_width="fill_parent"
    android:id="@+id/catagorySpinner" android:layout_marginLeft="10dip" android:layout_marginRight="10dip"></Spinner>
<TextView android:layout_height="wrap_content"
    android:layout_width="wrap_content" android:layout_below="@+id/catagorySpinner"
    android:id="@+id/postProcessLabel" android:text="Post process"
    android:layout_marginTop="10dip" android:textColor="@color/Black" android:layout_marginLeft="10dip"></TextView>
<Spinner android:layout_height="wrap_content"
    android:layout_below="@+id/postProcessLabel" android:id="@+id/postProcessSpinner"
    android:layout_width="fill_parent" android:layout_marginRight="10dip" android:layout_marginLeft="10dip"></Spinner>
<TextView android:layout_height="wrap_content"
    android:layout_below="@+id/postProcessSpinner" android:layout_width="wrap_content"
    android:id="@+id/priorityLabel" android:text="Priority"
    android:layout_marginTop="10dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:textColor="@color/Black"></TextView>
<Spinner android:layout_height="wrap_content"
    android:layout_below="@+id/priorityLabel" android:layout_width="fill_parent"
    android:id="@+id/prioritySpinner" android:layout_marginLeft="10dip" android:layout_marginRight="10dip"></Spinner>
<Button android:layout_height="wrap_content"
    android:layout_below="@+id/prioritySpinner" android:layout_width="wrap_content"
    android:id="@+id/downloadButton" android:text="Download" android:layout_marginLeft="10dip" android:layout_marginRight="10dip"></Button>

1 个答案:

答案 0 :(得分:1)

我认为你必须删除对话框上的标题框。在我的Dialog中,我使用此代码requestWindowFeature(Window.FEATURE_NO_TITLE);