Positioning AndroidSlidingUpPanel to a specific height

爱⌒轻易说出口 提交于 2019-12-05 19:10:59

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.

+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

yo can add android:layout_weight="0.85"

to your second child of SlidingUpPanelLayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!