0

Since my app lags during left/right transitions between fragments in a ViewPager2, I decided to disable its native swipe function with viewPager2!!.isUserInputEnabled=false. However, this also disabled the blue colored edge effect when swiping horizontally for fragments at either ends.

As my fragments also use vertical ScrollView, I noticed that the top and bottom edge effects work. Therefore, could it be possible to add left and right edge effects to a custom/extended vertical ScrollView? I believe left and right edge effects already are in place for horizontal ScrollView.

I also found the documentation regarding EdgeEffect where android.widget.EdgeEffect also can be extended:

class Edge(context: Context) : EdgeEffect(context) {
    // override functions
}

However, I don't know how I can apply it in order to add left/right edge effect to a vertical ScrollView.

Erlend K.H.
  • 448
  • 6
  • 21

1 Answers1

0

There is no need to use a Viewpager if you don't want the fragments to be swipeable. Replace your ViewPager element with a Framelayout and add your fragment to this framelayout programatically.

NIKHIL AGGARWAL
  • 448
  • 4
  • 9
  • Hello, actually, I wanted to have swipe but without the transition animation. As far as I know, the animation cannot be made instant with ViewPager2 since it's final, so I just disabled its swipe and added a custom implementation for it. I also have a TabLayout that I still use for the fragments. – Erlend K.H. Apr 06 '20 at 12:00