Jetpack Compose vs Oldskool xml layouts: interoperability and how you can gradually migrate your code base to start using Compose.
Recently I started working on a new project again, back to my main trade: Android Development. Before that I worked on some personal projects developing for web in React/NodeJs for a little over half a year and before that working for a while on projects that contained lots of legacy code and hadn’t caught up with the latest technologies.
So being a little behind on the latest developments in the Android world and with Compose maturing into version 1+ and promising performance improvements & writing your UIs faster and with less code I thought it was about time to dive deeper into Compose. In this post I’ll explore some of the basics and look into Compose’s interoperability with the oldskool style of creating UI via xml layouts.
Interoperability being an important keyword here as most projects will still have lots of xml layouts in them and probably will make use of them for quite a while. But it seems to be relatively easy to start integrating Compose Layouts into existing xml layouts giving us a way to gradually migrate our existing UI related code to start using Compose.
In the example below I’ll show a basic layout setup using both xml layouts as well as Composable layouts…