Open Percentage of SlidingDrawer in Android
Asked Answered
R

1

6

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?

Ricoriki answered 14/6, 2011 at 1:15 Comment(0)
M
1

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.

Marble answered 19/6, 2012 at 20:2 Comment(1)
this isn't really an answer, but you make a great point which is that this should definitely be custom built, but I am surprised they didnt add an API for that... and yeah I don't care anymore hahaRicoriki

© 2022 - 2024 — McMap. All rights reserved.