https://developer.android.com/develop/ui/compose/layouts/basics
Often these building blocks are all you need
You can write your own composable function to combine these layouts into a more elaborate layout that suits your app
Android Compose handles nested layouts efficiently, making them a great way to design a complicated UI
This is an improvement from Android Views, where you need to avoid nested layouts for performance reasons.
@Composable
fun ArtistCardColumn() {
Column {
Text("Alfred Sisley")
Text("3 minutes ago")
}
}
Use Row to place items horizontally on the screen. Both Column and Row support configuring the alignment of the elements they contain
@Composable
fun ArtistCardRow(artist: Artist) {
Row(verticalAlignment = Alignment.CenterVertically) {
Image(bitmap = artist.image, contentDescription = "Artist image")
Column {
Text(artist.name)
Text(artist.lastSeenOnline)
}
}
}
Use Box to put elements on top of another. Box also supports configuring specific alignment of the elements it contains.
@Composable
fun ArtistAvatar(artist: Artist) {
Box {
Image(bitmap = artist.image, contentDescription = "Artist image")
Icon(Icons.Filled.Check, contentDescription = "Check mark")
}
}
@Composable
fun ArtistCardArrangement(artist: Artist) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End
) {
Image(bitmap = artist.image, contentDescription = "Artist image")
Column { /*...*/ }
}
}