2016-10-12 17 views
3

リストビューを使用するビューページャーからフラグメントを膨らませました。リストビューでは、ロリポップ前のデバイスでsetNestedScrollingEnabledがサポートされていません。だから、リストビューをNestedScrollView内に追加しましたが、リストをスクロールするとスクロールしません。ListViewがアンドロイドのNestedScrollViewの中でスクロールしていません

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:id="@+id/fragment_item_view" 
    android:background="@color/white" 
    android:isScrollContainer="true"> 

<ProgressBar 
    style="?android:attr/progressBarStyle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/progressBar" 
    android:layout_centerInParent="true" /> 

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipe_refresh_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="none" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:fillViewport="true"> 
     <ListView 
      android:id="@+id/list_item_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="vertical" 
      android:clipToPadding="false" 
      android:divider="@color/gray_stroke_color" 
      android:dividerHeight="0.5dp" 
      android:paddingBottom="@dimen/padding_64dp"    > 
     </ListView> 

    </android.support.v4.widget.NestedScrollView> 

</android.support.v4.widget.SwipeRefreshLayout> 

</RelativeLayout> 

誰も私には何か解決策を提案できますか?前もって感謝します。

+1

ListViewではなくRecyclerViewを使用してください。 –

+0

これは私が知る最後の解決策です。しかし、大きなノーがあります。私のプロジェクトのリストビューのだから、それらのすべてを変更することは時間がかかります。誰でもリストビューで私を助けることができるなら、それは素晴らしいことでしょう。リストビューは、(真) –

+1

あなたは、ListViewコントロールの上にscrollViewを必要としません。 APIレベル21以上でのみ動作しています。私は21以下のAPIレベルについて話しています。 – Beloo

答えて

2

は、私はそれはそれの全体の高さ/幅は親だ取り上げる場合は、ScrollView内のリストビューを使用する理由わからない

setNestedScrollingEnabled(true); 
+0

setNestedScrollingEnabledをスクロール所有しているため、 –

1

を使用してみてください。

フラグメントのルートレイアウトでListViewを使用し、ScrollViewを削除することをお勧めします。それはNestedScrollingChildを実装して

<android.support.v4.widget.SwipeRefreshLayout 
android:id="@+id/swipe_refresh_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <ListView 
     android:id="@+id/list_item_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="vertical" 
     android:clipToPadding="false" 
     android:divider="@color/gray_stroke_color" 
     android:dividerHeight="0.5dp" 
     android:paddingBottom="@dimen/padding_64dp"/> 

    </ListView> 

</android.support.v4.widget.SwipeRefreshLayout> 

また、私はRecyclerViewの代わりに、リストビューを使用してお勧めします。

しかし、あなたはあなたのレイアウトで、ネストされたスクロールビューを持つ上で設定されている場合は、NestedScrollViewが親またはリスト中の子スクロールビューとして動作するように意図されていることを理解する必要があります。また、私はあなたがあなたの子ビューのレイアウト動作を設定しているので、あなたが多分CoordinatorLayoutを使用していることに気づいた

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

    <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="100dp"> 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"/> 

    </android.support.v4.widget.NestedScrollView> 

    <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="100dp"> 

     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"/> 

    </android.support.v4.widget.NestedScrollView> 

</LinearLayout> 
</ScrollView> 

:ここでは他の2 scrollviewsを含むscrollviewの良い例です。あなたのメインと唯一ScrollViewのために:リストビュー、RecyclerViewまたはNestedScrollView:もしそうなら、あなただけの「layout_behavior = 『@文字列/ appbar_scrolling_view_behavior』アプリ」を指定する必要があります。

0

あなたは

outerScrollView.setOnTouchListener(new View.OnTouchListener() { 

      public boolean onTouch(View v, MotionEvent event) { 
       findViewById(R.id.inner_scroll).getParent() 
         .requestDisallowInterceptTouchEvent(false); 
       return false; 
      } 
     }); 

     innerScrollView.setOnTouchListener(new View.OnTouchListener() { 

      public boolean onTouch(View v, MotionEvent event) { 
       v.getParent().requestDisallowInterceptTouchEvent(true); 
       return false; 
      } 
     }); 
0

使用ViewCompat.setNestedScrollingEnabled(スムーズスクロール用のタッチイベントをインターセプトする必要がある)と、あなたの問題が解決されます。

関連する問題