0

當我嘗試圍繞Google在其開發者社區支持中使用的邏輯圍繞我的大腦時,它使我瘋狂地開始拉扯我的頭髮(幸運地我是禿頂)。 我的意思是人們會期望谷歌正在間接提倡作爲其根容器的小部件NSV,可以與其他幾乎普遍使用的小部件recyclerview一起使用。那麼NestedScrollView和Recyclerview一起使用的判決是什麼?

這是如何跨越他們的想法超越了我。在API22令我們感到困惑之後,谷歌仍然沒有解決它們之間的問題。

我很抱歉浪費非生產性的咆哮。

我有什麼
我猜nothign將是新來的,因爲幾乎每個人都用甩掙扎裏面nestedscrollview得到了相同的設置來完成着想I.然而,這是我的觀點的支架。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"> 
    <android.support.design.widget.CoordinatorLayout 
     tools:ignore="RtlHardcoded"> 

     <android.support.design.widget.AppBarLayout 
      > 

      <android.support.design.widget.CollapsingToolbarLayout 
      > 


       <View 
        ></View> 

       <android.support.v7.widget.Toolbar 
        android:id="@id/tool_bar" 
        /> 
      </android.support.design.widget.CollapsingToolbarLayout> 
     </android.support.design.widget.AppBarLayout> 


     <android.support.v4.widget.NestedScrollView 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="100dp" /> 
      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"></android.support.v7.widget.RecyclerView> 
      </LinearLayout> 
     </android.support.v4.widget.NestedScrollView> 

     <com.roughike.bottombar.BottomBar 
      android:id="@+id/bottom_navigation_bar" 
      /> 
    </android.support.design.widget.CoordinatorLayout> 
</LinearLayout> 

問題 簡單! 。 RV應該WAI。當它停下來時,它應該拋起並停下來。在NSV的視野之下,雖然RV不會飛起來,但只要手指擡起,它就會停下來。

思考
哪這麼短的時間在我手上(客戶端總是這樣),以及所涉及的recyclerview和NSV滾動過程中,我實在是沒有動力多拿一支蠟燭,走進之間可能殘酷的技術性下面的陰影。

然而我跑出了選項,並控制+點擊RV。有人說這個問題與佈局經理有關。

我會在這裏發佈,如果我希望拿出一個解決方案。如果您有任何問題,請在這裏發表您的想法。

回答

0

我曾經遇到與recyclerview相同的問題。 將該值設置爲falsev(我不知道確切的方法名)

RV.setHasFixedSize(假)

+0

recyclerView.setHasFixedSize(false);我按照你的建議嘗試了這個。工作它沒有。 :| –

+0

你添加了nestedScrollingEnabled = true嗎? –

+0

nestedscrollingenabled是一個非常差的方法。它將完整的數據集加載到RV中並殺死回收。如果我在數據集中有一千行,它會加載所有這些行。這也會導致無盡的滾動問題。不幸的是,它不是一個選項 –

1

我猜你是因爲你在使用NSV RV面臨的問題。

只需使用RV作爲 -

....... 

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


         <LinearLayout 
          android:orientation="vertical" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent"> 
         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="100dp" /> 
         <android.support.v7.widget.RecyclerView 
        app:layout_behavior="@string/appbar_scrolling_view_behavior" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent"> 
</android.support.v7.widget.RecyclerView> 
         </LinearLayout> 

使用的應用程序:layout_behavior = 「@字符串/ appbar_scrolling_view_behavior」 在RV可以解決你的問題。

+0

如果我使用這個,我會遇到一個小問題。 LinearLayout內的TV和RV不會在其容器內向上滾動。這實際上是根據設計的要求。在textview和NSV的底部之間存在一些空間。拖動時,該空間將被填滿,RV應該開始滾動。 –

+0

如果您在LinearLayout中移動應用程序:layout_behavior =「@ string/appbar_scrolling_view_behavior」比。 TextView將移動到您的工具欄隱藏並保持可見狀態...... RV會正常滾動。但是如果你希望Textview也應該隱藏在RV上而不是使Textview成爲RV的一部分。 –

+0

這似乎是一個可以分析的建議。給我一點時間來測試一下。 –

相關問題