title: Getting null object reference error while using BottomSheetBehavior
body: <p>I created standard bottom sheet xml file
  and I included bottom sheet xml inside to fragment CoordinatorLayout.</p>
  <p>after compile and run app</p>
  <p>I encounterd this error</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.ourdesign, PID: 8015
  java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.View.getLayoutParams()' on a null object reference
      at com.google.android.material.bottomsheet.BottomSheetBehavior.from(BottomSheetBehavior.java:1479)
      at com.example.ourdesign.design.LowDesignFragment.onCreateView(LowDesignFragment.kt:55)
      at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
      at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
      at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
      at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
      at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
      at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
      at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
      at android.os.Handler.handleCallback(Handler.java:873)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6669)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  </code></pre>
  <p>i couldn't find reason</p>
  <p>this code is part of fragment kotlin file.</p>
  <pre><code>class LowDesignFragment : Fragment() {
  // TODO: Rename and change types of parameters
  private var param1: String? = null
  private var param2: String? = null
  
  // binding
  private lateinit var binding: FragmentLowDesignBinding
  
  // buttonSheet
  private lateinit var bottomSheetBehavior : BottomSheetBehavior&lt;LinearLayout&gt;
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      arguments?.let {
          param1 = it.getString(ARG_PARAM1)
          param2 = it.getString(ARG_PARAM2)
      }
  }
  
  override fun onCreateView(
      inflater: LayoutInflater, container: ViewGroup?,
      savedInstanceState: Bundle?
  ): View? {
      binding = DataBindingUtil.inflate(inflater, R.layout.fragment_low_design, container, false)
      bottomSheetBehavior = BottomSheetBehavior.from&lt;LinearLayout&gt;(standardBottomSheet)
      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED)
      binding.include.toggleButton.setOnCheckedChangeListener { _, isChecked -&gt;
          if (isChecked) {
              bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED)
          } else {
              bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED)
          }
      }
      return binding.root
  }
  </code></pre>
  <p>This code is fragment xml file.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:orientation=&quot;vertical&quot;&gt;
          &lt;!-- TODO: Update blank fragment layout --&gt;
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:id=&quot;@+id/constraintLayout2&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
          &lt;include
              android:id=&quot;@+id/include&quot;
              layout=&quot;@layout/low_design_bottom_sheet&quot;
              app:layout_anchorGravity=&quot;top|center&quot; /&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/imageView&quot;
              android:layout_width=&quot;403dp&quot;
              android:layout_height=&quot;659dp&quot;
              android:layout_marginStart=&quot;16dp&quot;
              android:layout_marginTop=&quot;16dp&quot;
              android:layout_marginEnd=&quot;16dp&quot;
              android:layout_marginBottom=&quot;16dp&quot;
              app:layout_anchorGravity=&quot;center&quot;
              tools:srcCompat=&quot;@tools:sample/backgrounds/scenic&quot; /&gt;
  
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p>This code is bottom sheet xml file.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:id=&quot;@+id/standardBottomSheet&quot;
      style=&quot;@style/bottom_sheet_row_style&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;vertical&quot;
      app:behavior_hideable=&quot;true&quot;
      app:behavior_peekHeight=&quot;?actionBarSize&quot;
      app:layout_behavior=&quot;com.google.android.material.bottomsheet.BottomSheetBehavior&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?actionBarSize&quot;
          android:orientation=&quot;horizontal&quot;&gt;
  
          &lt;ToggleButton
              android:id=&quot;@+id/toggleButton&quot;
              android:layout_width=&quot;36dp&quot;
              android:layout_height=&quot;36dp&quot;
              android:background=&quot;@drawable/ic_expand_less_black_36dp&quot;
              android:textOff=&quot;&quot;
              android:textOn=&quot;&quot;
              android:text=&quot;&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/editTool&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;Edit Tool&quot;
              android:textAlignment=&quot;center&quot; /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;&gt;
  
          &lt;LinearLayout
              style=&quot;@style/bottom_sheet_row_style&quot;
              android:layout_gravity=&quot;center&quot;&gt;
  
              &lt;ImageView
                  style=&quot;@style/bottom_sheet_element_image_style&quot;
                  android:contentDescription=&quot;@string/text&quot;
                  android:src=&quot;@drawable/ic_text_format_black_48dp&quot; /&gt;
  
              &lt;TextView
                  style=&quot;@style/bottom_sheet_element_text_style&quot;
                  android:text=&quot;@string/text&quot; /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout style=&quot;@style/bottom_sheet_row_style&quot;&gt;
  
              &lt;ImageView
                  style=&quot;@style/bottom_sheet_element_image_style&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:contentDescription=&quot;@string/text&quot;
                  android:src=&quot;@drawable/ic_text_format_black_48dp&quot; /&gt;
  
              &lt;TextView
                  style=&quot;@style/bottom_sheet_element_text_style&quot;
                  android:text=&quot;@string/image_size&quot; /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout style=&quot;@style/bottom_sheet_row_style&quot;&gt;
  
              &lt;ImageView
                  style=&quot;@style/bottom_sheet_element_image_style&quot;
                  android:src=&quot;@drawable/ic_text_format_black_48dp&quot; /&gt;
  
              &lt;TextView
                  style=&quot;@style/bottom_sheet_element_text_style&quot;
                  android:text=&quot;@string/template&quot; /&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>Do you know how to fix this problem?</p>