我意识到以下内容不正确,但我想您可以将其视为伪代码。我想知道,我怎样才能将整个布局“附加”到我的 RecyclerView 上,这样当我向下滚动时,布局也会随之滚动到看不见的地方。目前 RecyclerView 上方的 TextView 固定在屏幕上,而我的 RecyclerView 中的所有数据都是可滚动的。当用户向下滚动页面时,我希望 TextView 移出视线。如果你查看 Instagram,当你向下滚动页面时,画廊顶部的所有用户个人资料信息都会消失。我怎样才能做到这一点?如何以编程方式添加 TextView?
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello!" />
<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">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello!" />
</android.support.v7.widget.RecyclerView>
最佳答案
你可以试试Android-ObservableScrollView。
引用以下链接: https://github.com/ksoichiro/Android-ObservableScrollView
关于java - 将 TextView 附加到 RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34428590/