taltstidl / AndroidSlidingUpPanel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.
http://umano.me
Apache License 2.0
13 stars 6 forks source link

Make FAB follow the top of the panel #6

Closed NielsMasdorp closed 9 years ago

NielsMasdorp commented 9 years ago

Great fork! Do you know what I have to modify so that the FAB moves alongside the top of the panel (and not move to the bottom of the dragview) ?

taltstidl commented 9 years ago

@NielsMasdorp I was planning on adding additional modes for the FAB (see issue #4) but didn't have the time lately. Sorry for that! If you want to change the code yourself have a look at the ViewDragHelper in the library. I would love a pull request!

taltstidl commented 9 years ago

@NielsMasdorp More specifically: if you look into the code search for "if (mHasFloatingActionButton)". This should get you the two areas that actually change the FAB position. The line faby = y - mPanelHeight + mFabExpandedY; puts the FAB on top of the dragview (currently only used for anchor). So if you delete the rest this should work for you.

NielsMasdorp commented 9 years ago

No problem! thanks for your quick reply:) more modes would be awesome though if you want to reach more people (e.g. floating action button fade out etc.) Also you are using a older version. I will try to adjust the code, will let you know!

NielsMasdorp commented 9 years ago

@TR4Android if i remove all the other code that sets faby i get weird behaviour (fab dissapearing and reappearing in different spots) so i figure i have to do more then that..

taltstidl commented 9 years ago

@NielsMasdorp Have you done the same with the clampedY in the method dragTo( )?

taltstidl commented 9 years ago

I'll try to add this functionality next weekend. No promises though.

NielsMasdorp commented 9 years ago

@TR4Android Yes I did so that they both look like this:

if (mHasFloatingActionButton) { final int fabclampedY = clampedY - mPanelHeight + mFabExpandedY; final int faboldTop = mFloatingActionButton.getTop(); mFloatingActionButton.offsetTopAndBottom(fabclampedY - faboldTop); }

No promises needed! I'm not in a rush or anything, I just like to know how I can do it myself, still learning:)

taltstidl commented 9 years ago

@NielsMasdorp Hmm. I really don't know why this code wouldn't work. Maybe you should leave some of the other if statements in the code block. I wouldn't have thought of them as totally necessary, but it might solve the issue. Otherwise you'll have to wait till next weekend.

NielsMasdorp commented 9 years ago

No problem! Will try some stuff or wait for the weekend. Thanks for your help.

NielsMasdorp commented 9 years ago

@TR4Android By the way, it seems that the only place fabclampedY and faby are getting initialized is in the if(!mHasAchor){} block, so fabclampedY = clampedY - mPanelHeight + mFabExpandedY; isn't even used(with me atleast). I'm guessing the mFabRatio makes it moves up a little less so it ends up at the bottom of the panel. Not sure what ratio I should use so it follows the top though.

taltstidl commented 9 years ago

@NielsMasdorp This line is only used when the panel has an anchor set, so it's in the else{ } part of the statement. If you don't use an anchor point this code will thus not be used.

taltstidl commented 9 years ago

@NielsMasdorp This should now be supported with the new version. You have to add the attribute sothree:umanoFabMode="circular_reveal" to the FloatingActionButtonLayout in your layout and then it should give you the wanted behaviour.

taltstidl commented 9 years ago

@NielsMasdorp If you still have this issue or the new mode isn't quite what you wanted please reopen. Thanks!