Android 安卓对话活动会将整个屏幕而不是对话框取出

Android 安卓对话活动会将整个屏幕而不是对话框取出,android,android-relativelayout,Android,Android Relativelayout,我正在尝试设置一个假装对话的活动。 我希望它出现在屏幕的中间,但是它需要整个屏幕来代替,只显示灰色……/P> 我使用了relativeLayout,这是我的代码和屏幕截图- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:theme="@android:style/Theme.Di

我正在尝试设置一个假装对话的活动。 我希望它出现在屏幕的中间,但是它需要整个屏幕来代替,只显示灰色……/P> 我使用了relativeLayout,这是我的代码和屏幕截图-

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:theme="@android:style/Theme.Dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
tools:context=".TodoListManagerActivity">

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:minHeight="60dp"
    android:id="@+id/et_add_dialog_text"
    android:hint="@string/addDialogInsertTextHere"
    />

<DatePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:calendarViewShown="false"
    android:id="@+id/dp_add_dialog_date"
    android:layout_below="@+id/et_add_dialog_text" />

<Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Add!"
        android:id="@+id/btn_add_dialog_add"
        android:layout_below="@id/dp_add_dialog_date"
        android:layout_alignLeft="@id/dp_add_dialog_date"
    />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/addDialogCheckBoxNoDueDate"
    android:id="@+id/cbx_add_dialog_no_due"
    android:layout_below="@id/dp_add_dialog_date"
    android:layout_centerHorizontal="true"
    />

<Button
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Cancel"
    android:id="@+id/btn_add_dialog_cancel"
    android:layout_below="@id/dp_add_dialog_date"
    android:layout_alignRight="@id/dp_add_dialog_date"
    />
</RelativeLayout>

还有一张截图(废弃的地方用黄色标出)——

我在网上搜索,特别是在stackoverflow.com上,所有其他相关的问题都有“alignParentLeft”+“alignParentRight”两个组件,但我在代码中找不到这样的东西


提前感谢大家!:)

您需要将活动(假装是对话)的主题设置为对话。 在清单中输入以下代码

       <activity
        android:name=".About"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.Dialog" 
        >
        </activity>

工作很有魅力,谢谢!我首先在活动布局中添加了它,不知道它也应该在清单中:)很高兴它帮助了你。如果你得到了解决方案@Re'em,请将答案标记为正确
       android:theme="@android:style/Theme.Dialog"