0

My app contain a bottomsheeet and i am using following methods to change its state

 public void toggleBottomSheet() {
    if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
        sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}

But in some devices it is not showing animation properly ( Bottom to up ), It opens directly like popup. How to add animation so it looks it is coming from bottom.

1 Answers1

0

Not sure about this point of "in some devices", can you please mention the android version and other specifications? My suggestion is to add a BottomSheetBehavior.BottomSheetCallback to the BottomSheetBehavior

and in its onSlide method put a log.d() to check if its really sliding. It will help to find out the cause. Also, make sure that you have added the right BootmSheetBehavior and you can try by setting the peeckHeight explicitly.

  yourBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback()
    {
        @Override
        public void onStateChanged(@NonNull View view, int newState)
        {
            if (newState == BottomSheetBehavior.STATE_EXPANDED)
            {

            }
        }

        @Override
        public void onSlide(@NonNull View view, float v)
        {
            Log.d("tag", "sliding from bottom to top");

        }
    });
Md Tarik Mahmud
  • 331
  • 3
  • 8