2016-05-04 122 views
1

我有recycleview和頂部我有一個視圖,其中包括textview。recycleview與其他視圖同時滾動

我的問題是當向上滾動文本視圖始終在頂部和只有回收視圖滾動..是任何方式,我可以滾動兩者。我不想使用回收視景類型,因爲它已經使用一些其它目的

我的XML

<Rel layout> 
<text-view id="text"/> 
<recycle-view below="text" /> 

這樣的TextView將如何去向上和向下的循環視圖滾動可以在任何給小片段爲這個

+0

http://stackoverflow.com/questions/30756624/how-to-make-recyclerview-header-not-sticky的副本 – Irshu

+0

您必須添加您的標題作爲RecyclerView – Irshu

+0

中的第一項,正如我所說的那樣不能使用viewType – Does

回答

3

如果你真的想保持的TextView從RecyclerView分開,在NestedScrollView,而不是將它們包裝:

<NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
     <TextView /> 
     <RecyclerView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
    </LinearLayout> 
</NestedScrollView> 

當你設置您的RecyclerView,您可能需要撥打RecyclerView#setNestedScrollingEnabled(false),否則RV可能會消耗父母內部的某些滾動功能(您不需要)。

注意:這種做法使得RV將被迫佈置所有視圖,損失回收利益。正確的做法是正確地將viewType專門用於此TextView TextView的RV,而不處理將其封裝在其他ViewGroup中。

+0

即使這仍然在頂部。我的這個觀點是parsent觀點的subvivew有coridnt佈局與collasping tollbar – Does

+0

編輯。 NSV應該有一個孩子。實際上重要的是要知道你正在試圖用CoordinatorLayout來做這件事,因爲常規的ScrollView在CoordinatorLayout內部根本不起作用,只有NSV纔會這樣做。 – ekchang

+0

與此我的RecyclerView是不可滾動的,我必須修復高五 – andro

相關問題