Creating a horizontal scrolling intro screen similar to Google Docs in Android

I want to build an onboarding screen for my Android app that works like the one in Google Docs. You know, the intro screens that show up when you first open the app. I need it to have horizontal scrolling so users can swipe between different introduction pages. Each page should show some text and maybe an image to explain app features. I’m working in Android Studio and wondering what’s the best approach to create this kind of welcome screen. Should I use ViewPager or maybe RecyclerView with horizontal layout? I’ve seen this pattern in many apps but not sure how to implement it properly. Any code examples or guidance would be really helpful.

I did this exact thing six months ago and went with ViewPager2 plus a custom PagerAdapter instead of fragments. The fragment approach works great, but if you want something lighter, just inflate layouts directly in the adapter. Way faster for simple onboarding screens where you don’t need complex stuff. Handle the last page right - I threw in a ‘Get Started’ button that only shows on the final slide. You could add auto-advance with a timer if you want it to move automatically, but I think manual swiping gives users better control. Keep each page focused on one core feature so you don’t overwhelm new users.

ViewPager2 is definitely your best bet here. I built something similar last year - ViewPager2 with fragments gives you the smoothest experience. Create a fragment for each onboarding page and use FragmentStateAdapter to manage them. Add TabLayout or custom indicators at the bottom so users can track their progress. Pro tip: set offscreenPageLimit to preload the next fragment - it really improves performance. Don’t forget a skip button and proper navigation to your main activity when they’re done. The horizontal swiping works perfectly out of the box, way better than trying to hack RecyclerView for this.

i’d go with ViewPager2 too! it’s way easier than RecyclerView for this purpose. just set up some fragments for each page using FragmentStateAdapter. dont forget to add some page indicators for better user experience!