2016-05-03 24 views
0

私はScrollView内のRecyclerViewで23.2の問題を修正した最新のサポートデザイン(compile 'com.android.support:design:+')を使用しています。 RecyclerViewとExpandableListViewの両方のスクロールは完全に機能します。 ExpandableListViewが長すぎて、レイアウトを上にスクロールして残りの部分を見ることができるようにしたい場合、scrollviewは機能しません。ScrollView内のRecyclerView - ScrollViewが機能しません

フラグメント:

myRecyclerView = (RecyclerView) view.findViewById(R.id.myRecyclerView); 
    myRecyclerView.setNestedScrollingEnabled(false); 

    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false); 
    layoutManager.setAutoMeasureEnabled(true); 
    myRecyclerView.setLayoutManager(layoutManager); 

    MyListAdapter myListAdapter = new MyListAdapter(recyclerDataList, getActivity()); 
    myRecyclerView.setAdapter(myListAdapter); 

のxml:

<ScrollView 
      android:id="@+id/scrollView" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:fillViewport="true"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" > 

       <TextView 
        android:id="@+id/headerText" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="header text" 
        android:layout_marginRight="10dp"/> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/myRecyclerView" 
        android:layout_below="@id/headerText" 
        android:scrollbars="none" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 


       <ExpandableListView 
        android:id="@+id/expandableList" 
        android:layout_below="@id/myRecyclerView" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:divider="1dp" 
        android:dividerHeight="0dp" 
        android:groupIndicator="@null" 
        android:listSelector="@android:color/transparent" 
        android:showDividers="middle" > 
       </ExpandableListView> 

      </RelativeLayout> 
    </ScrollView> 
+0

これは重複していません。私のrecyclerviewはうまく動作し、問題はscrollview thaはrecyclerviewをthostsです。 – BVtp

答えて

0

あなたはこのようなスクロールビュー内のListViewや消耗品リストビューを使用することはできません、実行時にリストビューの高さを計算する必要があります。

Android list view inside a scroll view

0

あなたはこの方法を実行する必要があります。

RecyclerViewのOnItemTouchListenerを実装しACTION_MOVEに親タッチイベントを禁止します。

recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { 
    @Override 
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { 
     int action = e.getAction(); 
     switch (action) { 
      case MotionEvent.ACTION_DOWN: 
       recyclerView.getParent().requestDisallowInterceptTouchEvent(true); 
      break; 
      case MotionEvent.ACTION_UP: 
       recyclerView.getParent().requestDisallowInterceptTouchEvent(false); 
      break; 
      case MotionEvent.ACTION_MOVE: 
       recyclerView.getParent().requestDisallowInterceptTouchEvent(true);   
      break; 
     } 
     return false; 
    } 

    @Override 
    public void onTouchEvent(RecyclerView rv, MotionEvent e) { 

    } 

    @Override 
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { 

    } 
}); 

希望すると、これが役立ちます。

+0

残念ながらそれは動作しません:/ – BVtp

+0

@BVtp、私は私の答えを編集しました、確認してください –

+0

おかげで助けてください。残念ながら、それはどちらも役に立たなかった..私はとても欲求不満だ。 – BVtp

関連する問題