Search code examples
androidandroid-5.0-lollipopmaterial-designfloating-action-button

Android How to implement Bottom Sheet from Material Design docs


How do you implement the bottom sheet specficiation? http://www.google.com/design/spec/components/bottom-sheets.html

The new update to Google Drive shows this with the Floating Action Button press ->

enter image description here

Granted the specs never say anything about rounded corners, regardless it is possible to do, just unsure of how to go about it. Currently using the AppCompat library and target set to 21.

Thanks


Solution

  • Answering my own question so developers know that the new support library provides this finally! All hail the all powerful Google!

    An example from the Android Developer's Blog:

    // The View with the BottomSheetBehavior
    View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);  
    BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);  
    behavior.setBottomSheetCallback(new BottomSheetCallback() {  
       @Override  
       public void onStateChanged(@NonNull View bottomSheet, int newState) {  
         // React to state change  
       }  
    
      @Override  
      public void onSlide(@NonNull View bottomSheet, float slideOffset) {  
         // React to dragging events  
      }  
    });
    

    @reVerse's answer above is still a valid option but its nice to know that there is a standard that Google supports too.