На самом деле это довольно просто, я расширяю теоретический ответ здесь :
Создайте свой собственный макет, например, как myLayoutTitle. xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/select_type_title_container"
android:background="#f6f6f6">
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
app:layout_constraintLeft_toLeftOf="@+id/select_type_title_container"
app:layout_constraintTop_toTopOf="@+id/select_type_title_container"
android:text="@string/menu_types"
android:layout_gravity ="center_vertical"
android:gravity="center_vertical"
android:textStyle="bold"
android:textSize="20dp"
android:id="@+id/select_types_textview"/>
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
app:layout_constraintRight_toRightOf="@+id/select_type_title_container"
app:layout_constraintTop_toTopOf="@+id/select_type_title_container"
android:layout_margin="5dp"
android:text="Done"
android:textColor="@color/colorPrimary"
android:id="@+id/done_select_types"
android:layout_gravity ="center_vertical"/>
</androidx.constraintlayout.widget.ConstraintLayout>
В вашем диалоговом окне
builder.setCustomTitle(activity?.layoutInflater?.inflate(R.layout.myLayoutTitle, null))