I'm facing an issue with displaying a BottomSheetDialogFragment on smaller devices when using Material3. The fragment is appearing 'cut off' or 'sliding' on some smaller devices.
Below is the code for my BottomSheetFilters and the associated XML layout.
class BottomSheetFilters : BottomSheetDialogFragment(R.layout.reproduction_filters_modal) {
private lateinit var fragmentView: View
private val mCheckBoxList = mutableListOf<MaterialCheckBox>()
@SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
...}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="12dp"
android:paddingTop="12dp">
......
</LinearLayout>
I've come across some solutions involving code-based theme creation, but I'm not well-versed in the subject, and most of them aren't using navigation in the same way I am. In my case, one fragment is calling another via findNavController, so the solutions I found aren't effective. Additionally, since I don't understand how to modify the internal themes, I haven't been able to find a solution.
Here's the call from my Home fragment to my Modal Fragment:
private fun setUpOpenModalButton() {
val fab = fragmentView.findViewById<Button>(R.id.btn_open_filters)
// fab.callOnClick()
val action = HomeDirections.actionMenuItemHomeToReproductionFilter()
val resultKey = "onFilterChangeKey"
fab.setOnClickListener {
setFragmentResultListener(resultKey) { _, _ ->
adapter.onFiltersChanged()
}
findNavController().navigate(action)
}
}
So, the ultimate question is, how can I make my BottomSheetModal consistently show all content without requiring the user to drag it up to view? This also extends to the future need to implement a TextInput inside it and have it above the keyboard.
Any help will be greatly appreciated. Thank you.
Example on a larger device (working):
Example on a smaller device (not working):