Open SlidingDrawer Percentage on Android

I am trying to determine the "open" percentage of SlidingDrawer in Android. It seems that there are only OnOpen, onClose and onScroll Listeners in the box. OnScroll provides only ways to determine when the scroll has ended and when the scroll has begun.

TouchEvents will not work, because SlidingDrawer can move without touching ...

I tried to capture the SlidingDrawer animation using getAnimation (), and then somehow figure out the percentage based on that), but it returns null as well as getLayoutAnimation ().

Any thoughts?

+6
source share
1 answer

A very late answer, and I'm sure you don't care, but someone else. :)

I don’t quite understand why you want a sliding drawer at all. Most likely, it’s easier and faster to write your own custom view, which allows you to enter and exit, rather than trying to use a sliding drawer. This way you will have more control.

Another thought is to try to get the visible child rectangle of the sliding drawer from its container using getChildVisibleRect , and calculate the visible percentage using getWidth in the drawer. I'm not at all sure this will work. :)

Good luck anyway.

+1
source

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


All Articles