V A
V A

Reputation: 131

Positioning AndroidSlidingUpPanel to a specific height

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??

Upvotes: 3

Views: 5366

Answers (3)

Omar Alnajjar
Omar Alnajjar

Reputation: 447

yo can add android:layout_weight="0.85"

to your second child of SlidingUpPanelLayout

Upvotes: 4

RexSplode
RexSplode

Reputation: 1505

+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

Upvotes: 4

Giulio Prina Ricotti
Giulio Prina Ricotti

Reputation: 132

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.

Upvotes: 7

Related Questions