Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
why Android dialog title not showing on android versions marshmallow?

I was trying to create a custom dialog here is my code :

        val myDialog = Dialog(this)
        myDialog.setContentView(R.layout.my_dialog)
        myDialog.setTitle("My Dialog!")
        myDialog.setCancelable(true)
        myDialog.show()

Here is my_dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<TextView
        android:text="Hello world!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:textSize="30sp"/>

</android.support.constraint.ConstraintLayout>

I have run this on android version lollipop It works fine here is screenshot on lollipop :

Dialog on Android version Lollipop

as you can see dialog title is showing but when I try to run this on Android version marshmallow title stop showing here is screenshot on marshmallow :

Dialog on android version marshmallow

as you can see dialog title not showing on android version marshmallow. I have try adding this line for showing title :

myDialog.create()

but title still not showing. what should I do?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Have you tried applying custom style... The dialog adopts the Style of the parent Activity which might have been set to NoTitle.

<style name="CustomDialog" parent="@style/Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">false</item>
</style>

On the java code

new AlertDialog.Builder(new ContextThemeWrapper(Context, R.style.Dialog))
over 4 years ago · Santiago Trujillo Denunciar

0

Use AlertDialog instead of Dialog.

  AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle(getString(R.string.app_name));
        alertDialogBuilder.setMessage(getString(R.string.disclaimer))
                .setCancelable(false)
                .setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.dismiss();
                            }
                        });
        AlertDialog alert = alertDialogBuilder.create();
        alert.show();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda