Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Percentage of SlidingDrawer in Android

I am trying to determine the "open" percentage of a SlidingDrawer in Android. It seems that the drawer only has onOpen, onClose and onScroll Listeners. OnScroll only provides methods for determining when scroll has ended and when scroll has begun.

TouchEvents won't work either because the SlidingDrawer can slide without being touched...

I tried grabbing the Animation of the SlidingDrawer using getAnimation() (and then somehow determining percentage based on that) but that returns null and so does getLayoutAnimation().

Any thoughts?

like image 447
citizen conn Avatar asked Jun 14 '11 01:06

citizen conn


1 Answers

Very late answer, and I'm sure you don't care anymore, but someone else might. :)

I'm not entirely sure why you want a sliding drawer at all. It is likely easier and faster to write your own custom view that allows you to slide in and out, than to try to use sliding drawer. That way you will have way more control.

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

Best of luck either way.

like image 186
Mikael Ohlson Avatar answered Oct 21 '22 18:10

Mikael Ohlson