gpt4 book ai didi

java - 使用 SlidingUpPanel 库将 View 保持在底部

转载 作者:搜寻专家 更新时间:2023-10-30 21:26:31 27 4
gpt4 key购买 nike

我正在使用 SlidingUpPanel library在我的一个 Media Player 应用程序中。

在滑动面板中,我有媒体控件,我想在顶部显示轨道的插图。我遇到的问题是我希望媒体控件始终位于屏幕底部(即使用户正在拖动面板,这意味着我必须使用 onPanelSlide () 方法).也许像视差效果(不确定这是不是正确的名称)。这是我现在拥有的:

折叠/展开/拖动:
enter image description here enter image description here enter image description here

如您所见,当我拖动面板时,控件会粘在顶部。我希望它固定在屏幕底部,并在其正上方显示艺术品。

我在考虑 CoordinatorLayout,但我不知道它是如何工作的!

我的代码:

activity.xml

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="92dp"
sothree:umanoShadowHeight="4dp">

<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<include layout="@layout/details_slide_bar" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>

details_slide_bar.xml

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:orientation="vertical">

<ImageView
android:id="@+id/ivArtworkBar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="gone"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="92dp"
android:orientation="horizontal"
android:id="@+id/lDetailsBar">

/!-- Content of the detalBar !-->
</RelativeLayout>
</LinearLayout>

目前,我只是检查面板的状态并相应地调整艺术品的可见性

The Main Activity (MyListActivity.java)

一定有别的办法!

最佳答案

首先,在您的 Activity 的 onCreate 中

mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

然后设置面板状态为collapsed。

 mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
mLayout.setEnableDragViewTouchEvents(false);
mLayout.setDragView(null);
mLayout.setEnabled(false);
mLayout.setClickable(false);

此外,如果您的滑动面板不可见,则

mLayout.setPanelHeight(your panel height);

此处您的面板高度 值必须是整数。甚至你可以像 mLayout.setPanelHeight(your_drag_layout.getHeight());

这样动态地做

关于java - 使用 SlidingUpPanel 库将 View 保持在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37603104/

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