This simple class:
class DateSelectionDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val calendar = Calendar.getInstance()
val year = calendar.get(Calendar.YEAR)
val month = calendar.get(Calendar.MONTH)
val dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)
return DatePickerDialog(requireContext(), this, year, month, dayOfMonth)
}
}
results in strangely behaving buttons. What's important I didn't specify any style for the dialog. The DialogFragment
is from androidx.fragment.app
package.
The problem comes from Theme.MaterialComponents.Light.NoActionBar
.
It's pretty new (and alpha) and it should replace Theme.Design.Light.NoActionBar
but as we can see, it's not good enough yet.
Your solution would be to just use Theme.Design.Light.NoActionBar
.
But if you really want to use Theme.MaterialComponents.Light.NoActionBar
... The problem is caused by this setting in theme:
<item name="viewInflaterClass">com.google.android.material.theme.MaterialComponentsViewInflater</item>
You could replace it with another *ViewInflater
and there is not much choice but:
<item name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item>
It works, but I would not rely on it too much, as using Inflater from another package might cause weird issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With