How to remove the title of a Custom Dialog?

3

I have this Custom Dialog

AndI'dliketoknowhowtogetthatpartofthetitlebecauseinthiscase,it'sunnecessary.

Code

privatevoidacertou(){finalDialogcerto=newDialog(this);certo.setContentView(R.layout.resultado_positivo);ButtonokPositivo=(Button)certo.findViewById(R.id.okPositivo);okPositivo.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewe){dinheiro+=600;actualizarRecompensa();certo.dismiss();}});certo.show();}

AndintheXML

<?xmlversion="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>
    
asked by anonymous 18.09.2016 / 20:38

1 answer

5

In the file /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 style when creating 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);
    
19.09.2016 / 00:03