Я нашел решение. Диалог можно использовать вместо DialogFragment.
class AddPlaylistPopUp(context: Context, themeResId: Int) : Dialog(context, themeResId) {
init {
window?.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.add_playlist_popup_layout)
popUpContainer.setOnClickListener { dismiss() }
popUpCard.setOnClickListener {}
}
}
это можно использовать так:
private fun openDialog(){
val addPlaylistPopUp = AddPlaylistPopUp(this.context!!, R.style.DialogAlertTheme)
addPlaylistPopUp.show()
}
это стиль:
<!-- Dialog theme -->
<style name="DialogAlertTheme">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
Я также немного изменил раскладку:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:id="@+id/popUpContainer"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="239dp"
android:background="#00f"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/popUpBackground"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/popUpCard"
android:layout_width="match_parent"
android:layout_height="210dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/pop_up_shape"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:focusable="false"
android:clickable="false"
>
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Результат такой, какой я хочу: