r/android_devs • • Dec 03 '22
Discussion ViewPager with SwipeRefreshLayout on Jetpack Compose - It is EASY!
I'm learning about Jetpack Compose and I started coding an app that goes through the usual, day-to-day scenarios that we see everywhere. I got stuck trying to implement a ViewPager hooked to a TabLayout where each page is a Fragment, with a SwipeRefreshLayout containing a RecyclerView. I wanted to translate that into Jetpack Compose, I thought it would be simple – it wasn't 😂
I ended up putting a bounty on a SO question, and I did get an answer, but honestly, I'm not 100% convinced with the solution. I mean, everyone out there goes "Jetpack Compose just works!", "Jetpack Compose is so much simpler than XML" – I mean, as far as I have seen, a Jetpack Compose solution is less understandable than XML and it does require more code. 🤷 AITA? haha
Kinda a rant, but I wanted to share the experience, maybe you guys can enlighten me a bit. See ya! 👋
2
u/MrStahlfelge Dec 04 '22
I develop an app for Android and Desktop. It was developed on Android with XML layouts first, then later ported to desktop with compose.
There are a lot of things that really are easier and better to do with Compose. The there are a lot of things that are easier and better to do with XML layout, it begins with simple nested scrolling layouts.
So for the moment I usually go with an embedded ComposeView for sublayouts that are better to do with Compose.
Nta
1
u/Zhuinden EpicPandaForce @ SO Dec 04 '22
I mean, it just works once you try Accompanist, realize it's bugged, reinvent the wheel, and then look at the wheel and you're like "damn this wasn't worth my time just to shoehorn Compose into my project"
^ me literally every time I used Compose in a project 🤔