1

RecyclerviewNestedScrollViewにあります。私がrecycleview.scrollToPosition(X)またはrecycleview.getLayoutManager().scrollToPosition(X)と言うとき、全く動作しません。Recyclerview scrollToPositionはNestedScrollViewでは機能しませんか?とにかくありますか?

recycleviewnestedScrollViewから移動してもうまく動作しますが、レイアウト構造のためにできません!何か案が?

scrollingView.requestChildFocus(recyclerView,recyclerView); 

はこれを試してみましたが、特定の位置

+0

のようなあなたのrecyclerviewを作るあなたは 'recyclerViewを試してみました.smoothScrollToPosition(position) '? – jlively

+0

それは動作しません。私のrecyclerlerviewはnestedscrollviewの内部にあります。 –

+1

あなたは何か答えを見つけましたか? – praj

答えて

3

に焦点を当てていないが、この

<LinearLayout 
     android:id="@+id/ll2" 
     android:focusableInTouchMode="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:clipToPadding="false" 
       android:visibility="visible"/> 

</LinearLayout> 

とJavaコード

ItemsArrayList.add(0, items5); 
adapter.notifyDataSetChanged(); 
NestedScrollView nestedScrollingView = (NestedScrollView) findViewById(R.id.nestedScrollingView); 
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll2); 
float y = fcRecyclerView.getChildAt(0).getY(); 
float z =linearLayout.getY(); 
nestedScrollingView.smoothScrollTo(0, (int) z); 
+0

それは動作しません。私のrecyclerlerviewはnestedscrollviewの内部にあります。 –

+0

が更新されましたans –

+0

それは動作しません。 –

関連する問題