3

I am exploring https://github.com/umano/AndroidSlidingUpPanel library. When I slide the bottom panel, on slide complete it acquires complete screen area.

Can anyone help me, How to stop the bottom panel to a certain height, for e.g. slide it till middle of screen??

V A
  • 131
  • 1
  • 7

3 Answers3

7

Have you considered using setAnchorPoint(float)?

From the DemoActivity in the SlidingUpPanelDemo project

SlidingUpPanelLayout layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
layout.setAnchorPoint(0.3f);

this will make the panel slide to 30% of the screen height.

  • Did the anchor point setting work ?? I couldn't restrict the sliding by setting anchor point. – Atmaram Nov 26 '14 at 07:48
  • it works but only the half of the bottom panel is showing. is there any solution for resizing the bottom panel according to the change in slideup panel – Sharon Joshi Jun 14 '19 at 06:09
4

+1 to @Guilio Prina Ricotti answer. To make it work, after you call

SlidingUpPanelLayout layout = (SlidingUpPanelLayout)findViewById(R.id.sliding_layout);
layout.setAnchorPoint(0.3f);

in the code, which triggers your slidind layout (for example, onClickListener), instead of calling slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); call

slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.ANCHORED);

Also don't forget to make your sliding component's height to be match_parent

RexSplode
  • 1,475
  • 1
  • 16
  • 24
  • I wanted to ask one thing, I used the `setAnchorPoint(0.5f)` method to anchor the sliding panel to a half the screen height, upwards .but when I start dragging the panel upwards then it moves upwards.My requirement is that I don't want to slide the panel upwards, I only want the layout to be anchored to half the screen as I drag up and when I drag it down then it should take the panel downwards – Samarth Kejriwal Feb 06 '17 at 07:44
  • @SamarthKejriwal, have you found a solution, i also have the same requirment but cant seams to get it work that way – suulisin Jun 07 '17 at 12:52
  • I', afraid you'll have to use another library or write your own component for that. I didn't find a way to make it. – RexSplode Aug 01 '17 at 08:24
4

yo can add android:layout_weight="0.85"

to your second child of SlidingUpPanelLayout

Omar Alnajjar
  • 427
  • 5
  • 10