How to scroll to a particular position in recyclerview inside scrollview? How to scroll to a particular position in recyclerview inside scrollview? android android

How to scroll to a particular position in recyclerview inside scrollview?


Need to scroll ScrollView by getting top position of RecyclerView's child :

float y = recyclerView.getY() + recyclerView.getChildAt(selectedPosition).getY();    scrollView.smoothScrollTo(0, (int) y);


you can use scroll view method to reach your desired locations as:

scrollView.smoothScrollTo(int x, int y);


I know I'm answering pretty late but if you get an auto scroll issue, you need to add android:descendantFocusability="blocksDescendants" in your RelativeLayout. So, your RealtiveLyout tag will look like this:

<RelativeLayout    android:id="@+id/inclusionviewgroup"    android:layout_width="match_parent"    android:descendantFocusability="blocksDescendants"    android:layout_height="match_parent">