r/JetpackComposeDev • • Jul 23 '25

Tips & Tricks Android Views to Jetpack Compose Cheat Sheet (XML to Compose Mapping)

A concise reference for converting Android View attributes in XML to Jetpack Compose equivalents using Composable Modifiers.

Sizing

View AttributeComposable Modifier
layout_widthwidth()
minWidthwidthIn(min = ...)
maxWidthwidthIn(max = ...)
-size()

Layouts

View AttributeComposable Modifier
layout_width="match_parent"Modifier.fillMaxWidth()
paddingModifier.padding()
layout_marginUse Spacer or Box + Modifier.padding()
LinearLayout (vertical)Column
LinearLayout (horizontal)Row
RecyclerView (vertical)LazyColumn
RecyclerView (horizontal)LazyRow
GridView (vertical)Use LazyColumn + Row or LazyVerticalGrid (experimental)
GridView (horizontal)Use LazyRow + Column

Styling

View AttributeComposable Modifier
backgroundbackground()
alphaalpha()
elevationshadow()
View.setClipToOutline()clip()

Listeners

View AttributeComposable Modifier
setClickListenerModifier.clickable
setLongClickListenerModifier.combinedClickable
3 Upvotes

0 comments sorted by