Android bottomsheet - How i can set onSlide offset to 1 when card state is half_expanded?

Viewed 297

i have set my bottomsheet ot be half expanded using the folloiwng code:

 bottomSheetBehavior?.isFitToContents = false
 bottomSheetBehavior?.halfExpandedRatio = 0.6f

and it works fine. The issue is I have some content that changes alpha property as the card slides to halfway point. At the halfway expanded point, the alpha of the content should be 1. it works great without using isFitToContents = false, but when I do use it to half expand the card the slideOffset does not end at 1, for example, it ends at .019 because I just moved up a little bit to reach halfway expanded.

Therefore to my issue: How to make the half_expanded state slideOffSet end at 1 ?

another approach: if I could know the very last half expanded offset value then I can use that ahead of time as a scale factor. let's say that value was called halfExpandedOffSetEnd. then I could create a scale factor like this:

val multiplier  = 1/halfExpandedOffSetEnd

I could then multiply that by all my offsets to get the desired effect. but how would i get the very last offset value for half expanded ahead of time?

0 Answers
Related