【问题标题】:Sliding up Panel should slide up on a button click. Using the open source SlidingUpPanel from Umano App on GitHub向上滑动面板应在单击按钮时向上滑动。使用 GitHub 上 Umano App 的开源 SlidingUpPanel
【发布时间】:2014-01-03 16:36:48
【问题描述】:

嘿,我使用上滑面板,它是来自 Umano 应用程序的 GitHub 上的开源软件。 我在我的应用程序中实现了它并且它正在工作。 -> 当您单击面板或在其上拖动时,它会向上滑动。

但我希望它在我单击特定按钮时向上滑动。

有没有人使用过这种滑动面板并可以帮助我?

这里是开放代码:SlidingUpPanel on GitHub

【问题讨论】:

  • 你能添加 LinearLayout 作为第一个孩子吗?我试过了,它在图形布局中显示空指针异常。

标签: android github


【解决方案1】:

试试这个:

SlidingUpPanelLayout 布局;

布局 = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

当你要展开面板时放:

layout.expandPane();

当你尝试折叠面板时:

layout.collapsePane();

【讨论】:

  • 没有方法expandPane()
  • 你把这个库和 SlidingPaneLayout 混淆了,它只能在那里工作。
【解决方案2】:

这应该可行:

SlidingUpPanelLayout  layout = (SlidingUpPanelLayout) mView.findViewById(R.id.sliding_layout);

layout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);

【讨论】:

  • 这很奇怪,您使用的是哪个版本的库?我从我的代码中提取了这些行,对我来说它有效
  • 对我有用,但是幻灯片动画太快了。面板看起来像是在滑动之前跳到了屏幕中间。
  • @CraZyDroiD 您应该将第一行添加到您的“onStart”方法中,将第二行添加到按钮的“onClickListener”中,代码​​不会单独运行:)
【解决方案3】:

试试这个:

<Button 
 android:id="@+id/close_SlidingUpPanel"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
/>

在你的 java 代码中:

SlidingUpPanelLayout layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_up_panel);
layout.setDragView(findViewById(R.id.close_SlidingUpPanel));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多