如何制作对话框无标题?

问题描述:

我想没有标题,没有白色背景如何制作对话框无标题?

这个我layoute

<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; 
} 

如果你创建一个自定义对话框,你必须制作透明和WindowFeature无标题。像这样:

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) 
+0

谢谢你aziz – amirouche

在警告对话框中,使用

setTitle() 

OR

时只是传递null作为参数

只是把

setTitle(""); 

(这是非常不专业)