amirouche amirouche - 4 months ago 12
Android Question

how to mak dialogue box untitled?

I want to create a dialog without a title and without white background

this my 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

and this my code 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;
}

Answer

If you create a custom dialog , you have to make the setBackgroundDrawable TRANSPARENT and WindowFeature NO TITLE . like this:

    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)