How to remove a Custom Dialog title?

Asked

Viewed 177 times

3

I have this Custom Dialog inserir a descrição da imagem aqui

And I’d like to know how to take that part of the title because in this case, it’s unnecessary.

Code

private void acertou() {


    final Dialog certo = new Dialog(this);
    certo.setContentView(R.layout.resultado_positivo);

    Button okPositivo = (Button) certo.findViewById(R.id.okPositivo);

    okPositivo.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View e) {

            dinheiro +=600;
            actualizarRecompensa();

            certo.dismiss();

        }

    });

    certo.show();

}

And in the XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fundo_dialogos"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Correcto!!!"
        android:id="@+id/txtcerto"
        android:layout_gravity="center_horizontal"
        android:textStyle="bold"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OK"
        android:id="@+id/okPositivo"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/seleccionador"
        android:layout_marginTop="30dp"
        android:textColor="#ffffff"
        android:layout_below="@+id/txtcerto"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="5dp" />
</RelativeLayout>
  • How are you building the dialog? Enter the code.

  • There’s the code (I edited the question). XML and code in Java.

1 answer

5


In the archive /res/values/styles.xml declare a style added these lines:

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>

Use that style by creating the dialog:

final Dialog certo = new Dialog(this, R.style.CustomDialogTheme);

Another possibility is to use requestWindowFeature(Window.FEATURE_NO_TITLE)

final Dialog certo = new Dialog(this);
certo.requestWindowFeature(Window.FEATURE_NO_TITLE);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.