2016-06-14 24 views
5

我有以下佈局:ScrollView不扔光。滾動慢慢

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?android:attr/actionBarSize" 
    android:fillViewport="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:id="@+id/datatransfer_measure_list_layout_no_data" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/datatransfer_measure_list_textview_no_data" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="20dp" 
       android:layout_marginEnd="40dp" 
       android:layout_marginStart="40dp" 
       android:layout_marginTop="20dp" 
       android:gravity="center" 
       android:padding="5dp" 
       android:text="@string/measure_data_empty" 
       android:textColor="@color/textcolorprimary" 
       android:textSize="18sp" /> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:layout_gravity="center" 
       android:layout_marginBottom="20dp" 
       android:layout_marginEnd="20dp" 
       android:layout_marginStart="20dp" 
       android:background="@android:color/darker_gray" 
       android:importantForAccessibility="no" /> 
     </LinearLayout> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/datatransfer_measure_list_row_parent" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dp" 
      android:clipToPadding="false" 
      android:importantForAccessibility="no" 
      android:paddingBottom="5dp" 
      android:textColor="@color/textcolorprimary" /> 

     <Button 
      android:id="@+id/datatransfer_measure_list_button_send" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginBottom="10dp" 
      android:layout_marginEnd="40dp" 
      android:layout_marginStart="40dp" 
      android:background="@drawable/custom_button_ok" 
      android:gravity="center" 
      android:padding="10dp" 
      android:text="@string/common_save" 
      android:textColor="@drawable/custom_button_positive_text_color" 
      android:textSize="20sp" /> 

     <Button 
      android:id="@+id/datatransfer_measure_list_button_reset" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginBottom="20dp" 
      android:layout_marginEnd="40dp" 
      android:layout_marginStart="40dp" 
      android:background="@drawable/custom_button_cancel" 
      android:gravity="center" 
      android:padding="10dp" 
      android:text="@string/common_cancel" 
      android:textColor="@drawable/custom_button_negative_text_color" 
      android:textSize="20sp" /> 
    </LinearLayout> 
</ScrollView> 

我基本上這個佈局的三個部分。首先是一個僅包含文本視圖的佈局,以顯示是否未設置數據。有數據時它變得不可見。

第二部分是我的recyclerview,只有在設置了一些數據後才顯示出來。

最後一部分是兩個按鈕。我的問題與這種佈局? 滾動非常緩慢。我並不意味着落後或類似的東西。我只能滾動一小部分。這不像我的其他滾動視圖,我可以扔掉視圖,以便它自動滾動。我不知道這個佈局有什麼不同,爲什麼scrollview在這裏和我的其他佈局不同。有沒有阻止scrollview投擲或類似的東西?

回答

13

您的RecyclerviewScrollView碰撞,這就是爲什麼滾動不平滑。

嘗試禁用recyclerview的滾動。

RecyclerView recyclerView = (RecyclerView)findViewById(R.id.datatransfer_measure_list_row_parent); 
recyclerView.setNestedScrollingEnabled(false) 
+1

就是這樣。謝謝! – Mulgard