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

Add a button above Floating Action Button #8

Open Arash-gm opened 9 years ago

Arash-gm commented 9 years ago

Hi , first of all thank you for your nice work , but im struggling to add a button over FloatingActionButton with no success for couple of hours . i know that FloatingActionButtonLayout can have just two childs , so FloatingActionButton is my second child in my layout and it works just fine , but i wanted to add a ReleativeLayout to wrap the FAB and another Button above it , and it hides FAB even i replace RelativeLayout with a FrameLayout. i've also looked at your works and i've changed mFloatingActionButton = getChildAt(1) to : FrameLayout fl = (FrameLayout)getChildAt(1); mFloatingActionButton = fl.getChildAt(0);

in FloatingActionButtonLayout.java file but it doesn't change anything.i would be very happy to help me with this issue.

taltstidl commented 9 years ago

@Arash-gm The code currently assumes that the second child is a floating action button. I'm not sure I understand what result you want to achieve: do you want the whole RelativeLayout containing the FAB and your other button to move along, or do you only want the FAB to move?

Arash-gm commented 9 years ago

@Tr4Android: Thx for the response, actually I want my second button move according to fab movement, like Google map GPS button which GPS button is above the fab.for achieving rhis Ive thought that maybe a Relativelayout might does the job but that didnt work.

taltstidl commented 9 years ago

@Arash-gm If you want to achieve exactly the same behavior and layout as the GPS button on Google Maps you can try the following:

  1. Add the second FAB to the main layout inside the sliding up panel layout and add the appropriate margins to it.
  2. To animate the FAB when the panel gets hidden and shown use the onPanelSlideListener. It has two callbacks (onPanelHiddenExecuted( ) and onPanelShownExecuted( )) that also provide an Interpolator and a duration which you can use to translate the FAB using an ObjectAnimator. Hope this helps!
Arash-gm commented 9 years ago

@TR4Android : i will try that hope it works ;)

taltstidl commented 9 years ago

@Arash-gm Any update? Did it work?

Arash-gm commented 9 years ago

@TR4Android : for now I've added another button over it , but i have other problems to solve as i make PanelHeight to 1dp (because i wanted to panel collapse to most bottom part of screen) and make SlidingUpPanelLayout to use Fragment instead , FAB no longer attach to SlidingUpPanel.

taltstidl commented 9 years ago

@Arash-gm In order to hide the sliding up panel you could use setPanelState(PanelState.HIDDEN). That might be a cleaner solution than setting the panel height to 1dp.

Arash-gm commented 9 years ago

@TR4Android : I've tried that with no success in onPanelCollapsed i've set like this :

@Override
    public void onPanelCollapsed(View panel) {

        slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
    }

this line would get called but the panel won't get hidden,and the panel will be on the bottom of the page

Arash-gm commented 9 years ago

@TR4Android : also i wanted to use the view you are passing through your panel listeners but it throws : android.widget.FrameLayout cannot be cast to com.sothree.slidinguppanel.SlidingUpPanelLayout

taltstidl commented 9 years ago

@Arash-gm Any particular reason you are calling this from onPanelCollapsed()? Or do you just want the panel to disappear when the user collapses the panel? Also, the View panel passed in the listener is the panel itself, not the SlidingUpPanelLayout. I'm guessing you're using a FrameLayout for the fragment, so that's what's returned.

Arash-gm commented 9 years ago

yes its true i figured it out myself that it returns panel and not SlidingUpPanelLayout so i've used global slidingLayout to change its state to hidden but it doesn't change it's state.i wanted to make SlidingUpPanelLayout not visible to user when it collapse.

taltstidl commented 9 years ago

@Arash-gm Hmm. I would have thought that this works. I'll take a look at this issue.

Arash-gm commented 9 years ago

@TR4Android : Thx ;)

Arash-gm commented 9 years ago

@TR4Android : https://github.com/umano/AndroidSlidingUpPanel/issues/386

Arash-gm commented 9 years ago

@TR4Android : for a hint i've debug the library and when i've added Breakpoints and going through step by step it successfully hid the panel on smoothSlideTo(...) but when i exit debug mode it doesn't hid the panel.

taltstidl commented 9 years ago

@Arash-gm I didn't resolve the issue yet. It's rather strange because it should theoretically work. Thanks for the hint though :)

taltstidl commented 9 years ago

@Arash-gm This might be a timing issue causing the slide state of the panel to be changed to DRAGGING between the call to dispatchOnPanelCollapsed() and your call to setPanelState(PanelState.HIDDEN) and thus not calling the smooth slide. I'm not sure I know the code well enough to fix this though, so I guess it's better to wait for a fix.

Arash-gm commented 9 years ago

@TR4Android : unfortunately we don't have enough time to wait for next update of umano library maybe we should think of another solution . Thank you for your time and effort. much appreciated ;)

taltstidl commented 9 years ago

@Arash-gm I'll try to come up with some sort of hotfix, but no promises here :smiley:

taltstidl commented 9 years ago

@Arash-gm Unfortunately it seems like the issue is related to the smoothSlideTo() method itself which is not that easy to fix, so the only thing you can do for now is use setPanelHeight() to hide the panel correctly, maybe in conjuction with a call to invalidateLayout() on the FloatingActionButtonLayout. There probably will still be issues though, as the fab is positioned based on the panel state, and this isn't set properly when using setPanelState. Also, animation sadly will not work when using this.

taltstidl commented 9 years ago

@Arash-gm Anything I can do on that? Or did you find a solution?

Arash-gm commented 9 years ago

@Tr4Android : i've set panel height to 1 and hid the panel on a Handler with postDelay(500) and it just worked for now , maybe i should work more later on the issue.

taltstidl commented 9 years ago

@Arash-gm Ok. Good to know that you found a workaround. I'd wait till the original library gets updated to resolve this issue.