How to disable swiping in ViewPager2?
If you are using Android Data Binding you can simply disable it your layout xml file.
app:userInputEnabled="@{false}"
Now it is possible to enable-disable swiping viewpager2
using Version 1.0.0-alpha02
Use implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha02'
Version 1.0.0
New features
- Ability to disable user input (
setUserInputEnabled
,isUserInputEnabled
)
API changes
ViewPager2
class final
Bug fixes
FragmentStateAdapter
stability fixes
SAMPLE CODE to disable swiping in viewpager2
myViewPager2.setUserInputEnabled(false);
SAMPLE CODE to enable swiping in viewpager2
myViewPager2.setUserInputEnabled(true);