gpt4 book ai didi

android - Umano AndroidSlidingUpPanel 拖动高度为 0 的面板

转载 作者:行者123 更新时间:2023-11-30 00:55:33 25 4
gpt4 key购买 nike

我有一个关于 Umano AndroidSlidingUpPanel 的问题,我似乎没有找到解决方案。我想要两个 View ,一个在另一个之上,可以选择上下滚动,就像在 https://github.com/umano/AndroidSlidingUpPanel 的演示中一样。完美无缺。但是,我希望顶 View 在折叠时完全隐藏,就像 sothree:umanoPanelHeight="0dp"一样。这条线的问题是当高度为 0 时我无法到达面板。当您从左侧滑入菜单并从右侧滑回时,Google map 具有我想要的功能。

我的代码与演示中的代码非常相似,因此我认为没有必要在此处粘贴任何代码。我对解决此问题的其他选择持开放态度,但我需要向后兼容早期的 Android 版本。

感谢您对此的任何意见!

最佳答案

我想要一个类似的功能:我想将面板高度保持在 0 并在滑动时展开。

  1. 制作自定义布局并覆盖 onTouchIntercepted 方法
  2. 添加逻辑以从 Activity 中调用和设置回调事件(使用接口(interface))
  3. 在您的 Activity 中,通过 ID 找到自定义 View 并设置一个新的回调,在回调中将您的面板状态设置为 PanelState.EXPANDED

这是我从贡献者的 Github 页面获得的示例类:

public class SlidingAwareLinearLayout extends LinearLayout {
public SlidingAwareLinearLayout(final Context context) {
super(context);
}

public SlidingAwareLinearLayout(final Context context, final AttributeSet attrs) {
super(context, attrs);
}

public SlidingAwareLinearLayout(
final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

public SlidingAwareLinearLayout(
final Context context, final AttributeSet attrs, final int defStyleAttr,
final int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

@Override
public boolean onInterceptTouchEvent(final MotionEvent ev) {
SlidingUpPanelLayout panel = (SlidingUpPanelLayout) getParent();
if (ev.getAction() == MotionEvent.ACTION_DOWN
&& panel.getPanelState() == SlidingUpPanelLayout.PanelState.ANCHORED) {
panel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
return true;
}

return super.onInterceptTouchEvent(ev);
}
}

资源:https://github.com/umano/AndroidSlidingUpPanel/issues/476

关于android - Umano AndroidSlidingUpPanel 拖动高度为 0 的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40237732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com