Android BottomSheetBehavior onSlide () callback method gives confusing SlideOffset values

I am implementing an application in which I use the bottom sheet with the behavior defined @string/bottom_sheet_behavior. In addition, I installed the program code BottomSheetBehavior.BottomSheetCallback()because I want to use the onSlide () method to animate indentation. So I really need a slideOffset value to compute a new set. I read the docs . There they say that the value is in the range -1 to 0 when the state is between the hidden and minimized states. I only see this behavior when my phone or tablet is in portrait mode and does not depend on the version of Android. However, in landscape mode, the range varies from 1 to -1. Details here is a history of the values ​​of the bottom sheet coming from hidden to expand:

D/SLIDE: -0.86160713  
D/SLIDE: -0.5714286  
D/SLIDE: -0.29910713  
D/SLIDE: -0.0625  
D/SLIDE: 0.11382114  
D/SLIDE: 0.27235773  
D/SLIDE: 0.40650406  
D/SLIDE: 0.51626015  
D/SLIDE: 0.6300813  
D/SLIDE: 0.69512194  
D/SLIDE: 0.75609756  
D/SLIDE: 0.8130081  
D/SLIDE: 0.8577236  
D/SLIDE: 0.8943089  
D/SLIDE: 0.9186992  
D/SLIDE: 0.9430894  
D/SLIDE: 0.9593496  
D/SLIDE: 0.97154474  
D/SLIDE: 0.9796748  
D/SLIDE: 0.9878049  
D/SLIDE: 0.9918699  
D/SLIDE: 0.99593496  
D/SLIDE: 1.0

. -1 0,0 . , +1.
- , ?
- , .

.

+4
2

, , , , onSlide BottomSheetBehavior.BottomSheetCallback() ( -1 1), , , , 0, :

bottomSheetBehavior.setPeekHeight(0);

, onSlide (0 - 1).

, , .

+1

BottomSheetBehavior 3 "" :

  • STATE_EXPANDED
  • STATE_COLLAPSED
  • STATE_HIDDEN

:

[-1,1]. , . 0 1 -1 0 .

setHideable / STATE_HIDDEN.

0

Source: https://habr.com/ru/post/1658711/


All Articles