【问题标题】:Bottomsheet always hiding my last elements of RecyclerviewBottomsheet 总是隐藏我最后的 Recyclerview 元素
【发布时间】:2018-08-05 02:16:43
【问题描述】:

我的 recyclerview 的项目是动态加载的。底部表单 UI 是一个小型音乐播放器。我想在音乐播放器 UI 上方显示 recyclerview。但目前,音乐播放器 UI 隐藏了 recyclerview 的最后一个元素。音乐播放器的用户界面是动态隐藏/显示的。你能告诉我recyclerview的元素如何在不被底页UI(音乐播放器)阻碍的情况下全部显示吗? 这是我的布局

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_backdrop_height"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="200dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:fitsSystemWindows="true"
                android:scaleType="fitCenter"
                android:transitionName="@string/transition_album_cover"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <FrameLayout
        android:id="@+id/bottom_ui_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/bottom_sheet_behavior">

        <include layout="@layout/music_player_ui" />
    </FrameLayout>


</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

  • 你有没有尝试交换 FrameLayot 和 RecyclerView
  • 我认为这将使音乐播放器落后于recyclerview。这会阻碍音乐播放器用户界面
  • 是的,但我以为你想要这样
  • 我更新了问题以便更清楚
  • 暂时解决了recyclerview的下边距问题

标签: android user-interface android-recyclerview android-coordinatorlayout bottom-sheet


【解决方案1】:

尝试将RecyclerView 的高度设置为“0dip”,如果使用ConstraintLayout,请将RecyclerView 限制在父视图的顶部和底部。

【讨论】:

    【解决方案2】:

    您可以通过将回收站视图放在框架布局中来解决此问题。

    <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
    
                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/list"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scrollbars="vertical" />
    
            </FrameLayout>
    

    【讨论】:

      【解决方案3】:

      只需将 paddingBottom 和 clipToPadding="false" 设置为 recyclerView

      <android.support.v7.widget.RecyclerView
              android:id="@+id/my_recycler_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clipToPadding="false"
              android:paddingBottom="your_music_player_ui_height" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-26
        • 1970-01-01
        • 1970-01-01
        • 2017-05-12
        • 2010-10-01
        • 2019-06-02
        • 1970-01-01
        • 2015-07-08
        相关资源
        最近更新 更多