Comment créer un DialogFragment sans titre?

Je suis de la création d'un DialogFragment pour afficher certains messages d'aide concernant mon application. Tout fonctionne bien à part une chose: Il y a une bande noire en haut de la fenêtre qui affiche le DialogFragment, qui je présume est réservé pour le titre, quelque chose que je ne veux pas utiliser.

C'est particulièrement douloureux depuis mon custom DialogFragment utilise un fond blanc, de sorte que le changement est trop notoire pour être laissé de côté.

Permettez-moi de vous montrer de plus en plus graphique manière:

Comment créer un DialogFragment sans titre?

Maintenant le code XML pour mon DialogFragment est comme suit:

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

    <LinearLayout
        android:id="@+id/holding" 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:background="@drawable/dialog_fragment_bg"
        >
        <!-- Usamos un LinearLayout para que la imagen y el texto esten bien alineados -->
        <LinearLayout
            android:id="@+id/confirmationToast" 
            android:orientation="horizontal" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            >

            <TextView android:id="@+id/confirmationToastText" 
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" 
            android:text="@string/help_dialog_fragment"
            android:textColor="#AE0000"
            android:gravity="center_vertical"
            />

        </LinearLayout>
        <LinearLayout
            android:id="@+id/confirmationButtonLL" 
            android:orientation="horizontal" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:gravity="center_horizontal"
            >    
            <Button android:id="@+id/confirmationDialogButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginBottom="60dp"
                android:background="@drawable/ok_button">
            </Button>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Et le code de la classe qui implémente l'DialogFragment:

public class HelpDialog extends DialogFragment {

    public HelpDialog() {
        //Empty constructor required for DialogFragment
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //Inflate the XML view for the help dialog fragment
        View view = inflater.inflate(R.layout.help_dialog_fragment, container);
        TextView text = (TextView)view.findViewById(R.id.confirmationToastText);
        text.setText(Html.fromHtml(getString(R.string.help_dialog_fragment)));
        //get the OK button and add a Listener
        ((Button) view.findViewById(R.id.confirmationDialogButton)).setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                 //When button is clicked, call up to owning activity.
                HelpDialog.this.dismiss();
             }
         });
        return view;
    }

}

Et le processus de création de l'Activité principale:

/**
 * Shows the HelpDialog Fragment
 */
private void showHelpDialog() {
    android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
    HelpDialog helpDialog = new HelpDialog();
    helpDialog.show(fm, "fragment_help");
}

Je ne sais vraiment pas si cette réponse, en lien avec une boîte de Dialogue, correspond ici aussi Android: Comment créer une boîte de Dialogue sans titre?

Comment puis-je me débarrasser de cette zone de titre?

  • cette showHelpDialog méthode est appelée à partir de FragmentActivity ou de l'Activité de la classe??
  • +1... je pense que c'est la première fois que j'ai ri en lisant une question lol
  • +1 pour le sens de l'humour. Votre graphique explication du problème, c'est exactement comment je me sentais à propos de ce problème!
InformationsquelleAutor AlejandroVK | 2013-03-07