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 :
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 :
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?