I have scrollview inside Recycler view. I am trying to achieve swipeable behaviour like inshorts but the card should scroll to the bottom so user can see all the contents. Once scrollview bottom has been reached then swipe should work to move to next article.
I have implement swipeable behaviour using stacklayoutmanager. The problem is I am not able to scroll to the bottom.
Below is implementation
Recycler view inside main activity
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
MainActivity code, added PagerSnapHelper for fling effect.
adapter = new RecyclerViewAdapter(setData(),this);
layoutManager = new CustomLayoutManager(StackLayoutManager.ScrollOrientation.BOTTOM_TO_TOP,1, this);
layoutManager.setPagerFlingVelocity(600);
recyclerView.setLayoutManager(layoutManager);
LinearSnapHelper snapHelper = new CustomSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
recyclerView.setAdapter(adapter);
CustomLayoutManager class which extends the library for swipeable behaviour
class CustomLayoutManager(orientation: ScrollOrientation, count:Int, context: Context) : StackLayoutManager(orientation, count, context){
private var isScrollEnabled = true
fun setScrollEnabled(flag: Boolean) {
isScrollEnabled = flag
}
override fun canScrollVertically(): Boolean {
//Similarly you can customize "canScrollHorizontally()" for managing horizontal scroll
return isScrollEnabled && super.canScrollVertically()
}
}
item view inflated in adapter class
<ScrollView
android:id="@+id/scroll"
android:scrollbars="none"
android:nestedScrollingEnabled="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:text="very very long text will add here"
android:textSize="16sp" />
</ScrollView>
Here in the below image, when trying to scroll to the bottom to read the complete content but recyclerview swipe behaviour becomes active and next item becomes visible.
Update I have replaced scrollview with nestedscrolledview and found out that scrollVerticallyBy() method present in RecyclerView.LayoutManager() does not invoke, only scrollHorizontallyBy() is getting called n times.
I have tried so far but not working
ScrollView inside RecyclerView won't scroll
https://stackoverflow.com/a/41139693/7368819
https://stackoverflow.com/a/34060065/7368819