2016-05-31 82 views
1

我已經爲使用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"/> 
+0

你所描述的,可以通過使用新的'coordinatorLayout'很容易實現的。例子可以在互聯網上找到,但這是一個很好的例子:http://saulmm.github.io/mastering-coordinator – NSimon

回答

0

我認爲你需要類似CollapsingToolbarLayout的東西,你可以簡單地在你的項目中實現它。

看看這個guide 更多信息:)

+0

對不起,但我應該使用Recyclerview,請更確切地告訴我。 你可以在這裏寫詳細的例子嗎? –

+0

您應該將RecyclerView和CollapsingToolbarLayout一起使用......您是否看到我在答案中插入的指南鏈接? –

相關問題