23
23
import android .view .LayoutInflater ;
24
24
import android .view .View ;
25
25
import android .view .ViewGroup ;
26
+ import android .widget .FrameLayout ;
26
27
import androidx .annotation .LayoutRes ;
27
28
import androidx .annotation .NonNull ;
28
29
import androidx .annotation .Nullable ;
29
30
import androidx .core .view .WindowInsetsCompat ;
30
- import com .google .android .material .bottomsheet .BottomSheetBehavior ;
31
31
import com .google .android .material .bottomsheet .BottomSheetDialog ;
32
32
import com .google .android .material .bottomsheet .BottomSheetDialogFragment ;
33
33
import com .google .android .material .internal .ViewUtils ;
@@ -56,6 +56,7 @@ protected int getDemoContent() {
56
56
/** A custom bottom sheet dialog fragment. */
57
57
@ SuppressWarnings ("RestrictTo" )
58
58
public static class BottomSheet extends BottomSheetDialogFragment {
59
+
59
60
@ NonNull
60
61
@ Override
61
62
public Dialog onCreateDialog (@ Nullable Bundle savedInstanceState ) {
@@ -64,11 +65,13 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
64
65
new BottomSheetDialog (
65
66
getContext (), R .style .ThemeOverlay_Catalog_BottomSheetDialog_Scrollable );
66
67
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 );
70
73
71
- View bottomSheetContent = bottomSheetInternal .findViewById (R .id .bottom_drawer_2 );
74
+ View bottomSheetContent = content .findViewById (R .id .bottom_drawer_2 );
72
75
ViewUtils .doOnApplyWindowInsets (bottomSheetContent , (v , insets , initialPadding ) -> {
73
76
// Add the inset in the inner NestedScrollView instead to make the edge-to-edge behavior
74
77
// consistent - i.e., the extra padding will only show at the bottom of all content, i.e.,
0 commit comments