如何将mak对话框无标题?

时间:2016-07-24 09:32:28

标签: java android xml

我想创建一个没有标题且没有白色背景的对话框

这是我的伙伴

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/Image"
        android:id="@+id/fondBoxWin" />

I got the figure 1 And I want to get Figure 2

这是我的代码java

 @Override
public Dialog onCreateDialog(int identifiant) {
    Dialog box = null;
    //En fonction de l'identifiant de la boîte qu'on veut créer
    switch(identifiant) {
        case MY_BOX :
            box = new Dialog(this);
            box.setContentView(R.layout.mybox);
            break;
    }
    return box;
}

2 个答案:

答案 0 :(得分:0)

如果您创建自定义对话框,则必须设置setBackgroundDrawable TRANSPARENT和WindowFeature NO TITLE。像这样:

    final Dialog d = new Dialog(yourActivity.this);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.getWindow().setBackgroundDrawable(new   ColorDrawable(android.graphics.Color.TRANSPARENT));

    d.setContentView(R.layout.yourDialogLayout)

答案 1 :(得分:0)

在警告对话框中,只需在使用

时传递null作为参数
setTitle()

OR

刚刚放

setTitle("");

(这非常不专业)

相关问题