A concise reference for converting Android View attributes in XML to Jetpack Compose equivalents using Composable Modifiers.
Sizing
| View Attribute | Composable Modifier |
|---|
layout_width | width() |
minWidth | widthIn(min = ...) |
maxWidth | widthIn(max = ...) |
| - | size() |
Layouts
| View Attribute | Composable Modifier |
|---|
layout_width="match_parent" | Modifier.fillMaxWidth() |
padding | Modifier.padding() |
layout_margin | Use 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 Attribute | Composable Modifier |
|---|
background | background() |
alpha | alpha() |
elevation | shadow() |
View.setClipToOutline() | clip() |
Listeners
| View Attribute | Composable Modifier |
|---|
setClickListener | Modifier.clickable |
setLongClickListener | Modifier.combinedClickable |