0

Android Top Sheet Implementation

 1 year ago
source link: https://gist.github.com/jayrambhia/3860832353ccd22c8ce5478ef7ef63e4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

TopSheetDialog

Widget equivalent to Android's BottomSheet with top-to-bottom transition. This implementation reuses the Bottom Sheet implementation. With the same Behavior+CoordinatorLayout strategy, the implementation makes necessary changes to BottomSheetBehavior and creates a new behavior called TopSheetBehavior.

Similar to the behavior, I have also replicated BottomSheetDialog class and created TopSheetDialog class.

Usage

TopSheetDialog(context, <Your top-sheet theme>).apply {
  // Required to have the top-down animation when the app starts showing / dismissin it.
  window?.attributes?.windowAnimations = R.style.TopSheet_DialogAnimation 
  setContentView(<Your view>, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}.show()

TopSheetFragment?

I have not tried it with a fragment. Feel free to take the code and make necessary changes to make it work.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK