Android How to implement Bottom Sheet from Material Design docs

后端 未结 7 2462
一向
一向 2020-11-28 01:50

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

7条回答
  •  伪装坚强ぢ
    2020-11-28 01:58

    You can now use Official BottomSheetBehavior API from android support library 23.2.

    Below is sample code snippet

    bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottomSheet));
    
    case R.id.expandBottomSheetButton:
     bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
     break;
    case R.id.collapseBottomSheetButton:
     bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
     break;
    case R.id.hideBottomSheetButton:
     bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
     break;
    case R.id.showBottomSheetDialogButton:
     new MyBottomSheetDialogFragment().show(getSupportFragmentManager(), "sample");
    

    Please refer to Android BottomSheet youtube tutorial to get understanding on it.

提交回复
热议问题