Dialog Fragment is cropped on API 23 and lower

Viewed 148

I have 2 identical full screen Dialog classes (Dialogs A and B) that extend from DialogFragment (support library one) both look as expected while ran on devices with APIs 24+. The Dialogs differ in their implementations.

Dialog A - Overrides onCreateDialog and its height is cropped on API 23<=

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
    val inflater = requireActivity().layoutInflater
    val view = inflater.inflate(R.layout.fragment_cropped_dialog, null)
    // Setting data to views
    val builder = AlertDialog.Builder(activity)
    builder.setView(view)
    val dialog = builder.create()
    return dialog
}

enter image description here

Dialog B - Overrides onCreateView and is displayed full screen regardless of API

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
    val view = inflater.inflate(R.layout.fragment_not_cropped_dialog, container, false)
    // Setting data to views
    val builder = AlertDialog.Builder(activity)
    builder.setView(view)
    val dialog = builder.create()
    return view
}

enter image description here

Question: What is the reason the dialog A is cropped on API 23 and lower?

0 Answers
Related