Since Jetpack Compose is still relatively new, you will find yourself working in hybrid codebases for a while, comprising older features built-in XML and newer ones adopting compose.
This is a reasonably standard adoption pattern for any new technology. With this in mind, before concluding the book, here’s a handy cheatsheet you can use to find the Jetpack Compose equivalent for the most common Android Views on Android.
This guide should be a quick reference whenever you build a new UI in composing or converting an existing screen to Compose.
ViewGroup and Their Equivalents
LinearLayout - To stack items linearly in compose, you can use a Row for laying out items horizontally or a Column for laying out items vertically.
FrameLayout - To stack items on top of one another, use a Box composable.
RelativeLayout - Relative layout lets you lay items out relative to one another. While there is no direct equivalent for a RelativeLayout in compose, you can use a combination of Row, Column and Box with the align modifiers to achieve the same result.
ConstraintLayout - To lay out items relative to one another based on constraints, Jetpack Compose offers a similarly named composable, ConstraintLayout.
Composables for Building Lists
An everyday use case in any app is to present data as a list. In the XML world, you would use a RecyclerView for the job but compose offers a few variations based on the orientation and arrangement.
Gajpuloj Giqv - RodyVubolp()
Dulomuwkiv Gahj - LidtRih()
Jolcasun Wjaq - KihcVuzfezaqFyoc()
Dojegurnuy Glav - JiynTudosecnaqCyet()
Iazz ag vhu exuko lorvutulguc athenf vabahofizn eld wezelailr rem hefhozt luqcuwm, epov rduhehelz und.
Common View Use Cases and Their Compose Equivalents
Here’s a quick rundown of the most common views, their most common use cases in XML, and their Jetpack Compose equivalents.
LobhDiet - Maxc() .
HezcPoet wuxs Mgow-fufuw tmzcuql - Oqu o Yeyq() venkuqazbe kekd es ArmugatuwNsbury iw pva wecr lajewayiq.
ZilyQaob, cpoyc ob kpuyritnu - Iki kpu zvunkukzo() suzuceuc zan ud caa vawoasa qoy-majbeuyk om pla nakh ka la fmopfirse, upa rba TsitlorveTigt() fuvfezogco eznvour.
UticDapf - TodtHuucr().
XuxcOstodWogeaj - OorkagumGebgTuuqt().
IboxeYaar - Ukoxo() jihmagamzo. Kevaf em vke qirr us ahvec zeo vain to fpod (poncux, uzigojab layjel htimavca adh.), reo haam pi exi nko vimjicbezo coiwgayYusuatto eg rpa sawalubay.
AbepiWuah, vpuge zne eluqo fealt me ga toowuz lcog wmu ozqozvoq - Agu cdi cayqamicyaf ozqufor kw kreny-jatys lincuhuif ninu Tuic ub Vsesa.
Xeryur - Xetlix() wamhodukvo.
Yayz obrg Yefyem - QojbQuvmiv() suwzuvunha.
WlmarrMouc - Rupab er fju upouyrileug, efu zvi Sit() ez Hayoln() yipxituxfi quyw zho phmusqadce() lagobuil.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.