Update: This behaviour is happening due to using Theme.Material3, if I change that to Theme.Design only for the bottomsheet it fills the parent but this takes us to another problem which is the colours now are different, since I am using material you which gets the colours from the phones theme, I can't set the colours manually for the content of the bottom sheet.
I can't show the width of the bottomSheetFragDialog to match_parent, there is some sort of strange margin from the start and the end.
These screenshots I am getting from a new proj, no single line of code is written, so nothing could be changed.
I have added a placeholder content for the purpose of the demonstration, here is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello, World!"
android:textSize="100sp"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello, World!"
android:textSize="100sp"
android:gravity="center"/>
</LinearLayout>
Nothing in the xml layout is important, I am just putting anything.
Here is the Kotlin code that shows the sheet:
TestSheet().show(supportFragmentManager, TestSheet::class.java.canonicalName)
Also here is the code in the class TestSheet:
class TestSheet : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val v = inflater.inflate(R.layout.sheet_test, container, false)
(dialog as BottomSheetDialog).let {
it.behavior.state = BottomSheetBehavior.STATE_EXPANDED
it.behavior.skipCollapsed = true
it.behavior.isDraggable = true
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
dialog?.window?.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
return v
}
}
My issue: I can't get the BottomSheetFragmentDialog to be in fullscreen when the phone is rotated into landscape, instead I get what you see in the pic below, strange layout margin that I have not set. Thanks!