加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 使用SlidingUpPanel库保持底部的视图

发布时间:2020-12-15 00:27:34 所属栏目:Java 来源:网络整理
导读:我在我的一个媒体播放器应用程序中使用了 SlidingUpPanel library. 在幻灯片面板中,我有媒体控件,我想在顶部显示曲目的图稿.我遇到的问题是,我希望媒体控件始终保持在屏幕的底部(即使用户拖动面板,这意味着我必须使用onPanelSlide()方法).也许像视差效果(不
我在我的一个媒体播放器应用程序中使用了 SlidingUpPanel library.

在幻灯片面板中,我有媒体控件,我想在顶部显示曲目的图稿.我遇到的问题是,我希望媒体控件始终保持在屏幕的底部(即使用户拖动面板,这意味着我必须使用onPanelSlide()方法).也许像视差效果(不知道是否是正确的名称).这是我现在所做的:

折叠/展开/拖动:

正如你所看到的,当我拖动面板时,控件贴在顶部.我希望它坚持到屏幕的底部,并将艺术品放在正上方.

我正在考虑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>

现在,我只是检查面板的状态,并相应调整艺术品的可见度.

07004

必须有另一种方式!

解决方法

首先,在创建你的活动
mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

然后设置面板状态折叠.

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())动态地执行;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读