【问题标题】:How to dissappear top layout when scrolling down the recycleview向下滚动recyclerview时如何消失顶部布局
【发布时间】:2016-05-31 14:54:51
【问题描述】:

我使用 RecycleView 为 Android 应用程序开发。 我想知道,我怎样才能将整个布局“附加”到我的 RecyclerView 上,这样当我向下滚动时,布局滚动就会随之消失。目前 RecyclerView 上方的布局固定在屏幕上,而我的 RecyclerView 中的所有数据都是可滚动的。我希望布局在用户向下滚动页面时移出视线。如果您查看 Instagram,当您向下滚动页面时,画廊顶部的所有用户个人资料信息都会消失。我怎样才能做到这一点?如何滚动整个布局并禁用 Recycleview 的滚动?

<LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:paddingLeft="15dp"
                android:paddingBottom="0dp"
                android:textSize="14sp"
                android:fontFamily="sans-serif-light"
                android:textStyle="bold"
                android:typeface="sans"
                android:id="@+id/fullName"
                android:paddingTop="10dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:gravity="top"
                android:paddingLeft="15dp"
                android:paddingBottom="0dp"
                android:textSize="14sp"
                android:fontFamily="sans-serif-light"
                android:typeface="sans"
                android:id="@+id/bio"
                android:paddingRight="15dp" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginBottom="?android:attr/actionBarSize"
                android:padding="@dimen/item_margin"
                android:id="@+id/recycler_view"
                android:clipToPadding="false"
                android:visibility="visible"/>

【问题讨论】:

  • 您所描述的内容可以通过使用新的coordinatorLayout 轻松实现。示例可以在互联网上找到,但这里有一个非常好的示例:saulmm.github.io/mastering-coordinator

标签: android css xml android-layout android-recyclerview


【解决方案1】:

我认为你需要像CollapsingToolbarLayout 这样的东西,你可以简单地在你的项目中实现它。

看看这个guide 了解更多信息:)

【讨论】:

  • 对不起,我应该使用 Recyclerview,请告诉我更准确的信息。你能在这里写详细的例子吗?
  • 您应该同时使用 RecyclerView 和 CollapsingToolbarLayout...您看到我在答案中插入的指南链接了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-13
相关资源
最近更新 更多