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

标签 java android android-layout

我正在使用 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/

相关文章:

java - 检测 PDF 中丢失/损坏的 Unicode 映射

java - Spring "hello world"示例错误 : A JNI error has occured & NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory

android - Android 上适用于 Unity 的 Facebook SDK 尝试在不调用 FB.login 的情况下登录 FB.init

android - ViewPager 滑动不适用于 RecyclerView

java - 将 CSV 映射到模型

枚举值的 Java 数组

android - 为什么Android模拟器屏幕是空白的?

android - 如何通过代码在android中获取默认设备辅助应用程序?

android - 如何将基线对齐到多行 TextView 的底线?

android - 如何在微调器周围创建自定义微调器,如右侧向下三角形的边框?