2323import android .view .LayoutInflater ;
2424import android .view .View ;
2525import android .view .ViewGroup ;
26+ import android .widget .FrameLayout ;
2627import androidx .annotation .LayoutRes ;
2728import androidx .annotation .NonNull ;
2829import androidx .annotation .Nullable ;
2930import androidx .core .view .WindowInsetsCompat ;
30- import com .google .android .material .bottomsheet .BottomSheetBehavior ;
3131import com .google .android .material .bottomsheet .BottomSheetDialog ;
3232import com .google .android .material .bottomsheet .BottomSheetDialogFragment ;
3333import com .google .android .material .internal .ViewUtils ;
@@ -56,6 +56,7 @@ protected int getDemoContent() {
5656 /** A custom bottom sheet dialog fragment. */
5757 @ SuppressWarnings ("RestrictTo" )
5858 public static class BottomSheet extends BottomSheetDialogFragment {
59+
5960 @ NonNull
6061 @ Override
6162 public Dialog onCreateDialog (@ Nullable Bundle savedInstanceState ) {
@@ -64,11 +65,13 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
6465 new BottomSheetDialog (
6566 getContext (), R .style .ThemeOverlay_Catalog_BottomSheetDialog_Scrollable );
6667 new WindowPreferencesManager (requireContext ()).applyEdgeToEdgePreference (bottomSheetDialog .getWindow ());
67- bottomSheetDialog .setContentView (R .layout .cat_bottomsheet_scrollable_content );
68- View bottomSheetInternal = bottomSheetDialog .findViewById (R .id .design_bottom_sheet );
69- BottomSheetBehavior .from (bottomSheetInternal ).setPeekHeight (400 );
68+ View content =
69+ LayoutInflater .from (getContext ())
70+ .inflate (R .layout .cat_bottomsheet_scrollable_content , new FrameLayout (getContext ()));
71+ bottomSheetDialog .setContentView (content );
72+ bottomSheetDialog .getBehavior ().setPeekHeight (400 );
7073
71- View bottomSheetContent = bottomSheetInternal .findViewById (R .id .bottom_drawer_2 );
74+ View bottomSheetContent = content .findViewById (R .id .bottom_drawer_2 );
7275 ViewUtils .doOnApplyWindowInsets (bottomSheetContent , (v , insets , initialPadding ) -> {
7376 // Add the inset in the inner NestedScrollView instead to make the edge-to-edge behavior
7477 // consistent - i.e., the extra padding will only show at the bottom of all content, i.e.,
0 commit comments