我正在尝试修复滑动面板的扩展高度。我想要的是滑动面板布局只能扩展到屏幕高度的40%或50%。我尝试添加值为0.4的umanoAnchorPoint属性,但视图仍然可以拖动到全屏。
答案 0 :(得分:0)
你可以像这样使用滑动监听器:
slidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
if(newState == SlidingUpPanelLayout.PanelState.EXPANDED) slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.ANCHORED);
}
});
或者也许:
slidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
if(slideOffset > desiredOffset) slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.ANCHORED);
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
}
});