android-sliding-layer-lib
android-sliding-layer-lib copied to clipboard
Possible to tell when and which way the SlidingLayer is sliding?
I want to be able to have a sort of parallax effect and have the information in the background layer slide while the SlidingLayer slides in.
From what I can tell, the best way to do this would be if there were a Listener for when the SlidingLayer is sliding and then move the background layer depending on which direction the SlidingLayer is moving.
I am a bit confused by what exactly onOpened() vs onOpen() do in the OnInteractListener interface so my logic might be flawed on this, but here is my idea: I start sliding the background at a constant speed when onOpen() is called and then stop when onOpened() is called. I can then do the opposite with onClose() and onClosed(). I can see this working if sliding the layer open and close both take the same amount of time, but I am not sure about that.
Can someone help me out?
Well, as you can see in the code, the property which is being varied in this view is scrollX and scrollY, and these have getters. You have it by calling mSlidingLayer.getScrollX() (and scrollY). Nevertheless for that purpose I guess it'll help to have a listener that is called in every frame the scroll changes. Something like AbsListView.onScrollListener. With that you just need to get the scroll values and apply your parallax formula to move your view behind accordingly.
How would you recommend making something like an onScrollListener for the SlidingLayer?
I think it could make sense.
Yeah I think it makes sense too, but how would one make that kind of listener?
Easy dizzy. Just need to notify the listener whenever the position change. Probably within onTouch method MotionEvent.MOVE. It'd be wise to double check when is it happening in AbsListView for instance, but I'm sure it is enough with that.
On Jun 15, 2013, at 1:29 AM, Ankush Gupta wrote:
Yeah I think it makes sense too, but how would one make that kind of listener?
— Reply to this email directly or view it on GitHub.