Computer scienceMobileJetpack ComposeRefinement

Modifying Composables

Theory

Designing a page

Report a typo

You have been assigned to design a custom mobile app layout that presents content in an appealing visual manner.

There are the design requirements you need to follow:

  • Between content and screen spacing, 16 dp.

  • Between the spacing between rows, 8 dp.

  • Between the spacing between boxes, 4 dp.

  • Figure out the weight of boxes from the image.

After the necessary changes, your output needs to be like this;

Grey and pink code fields.

Fill in the gaps with the relevant elements
fun Modifier.cardDefault(color: Color) = then(height(48.dp).clip(RoundedCornerShape(16.dp)).background(color))

@Composable
fun CustomLayout() {
    Column(
        modifier = Modifier.,
        verticalArrangement = Arrangement.
    ) {
        Row(horizontalArrangement = Arrangement.) {
            Box(modifier = Modifier.cardDefault(Color.LightGray).)
            Box(modifier = Modifier.cardDefault(Color.LightGray).)
            Box(modifier = Modifier.cardDefault(Color.LightGray).)
        }
        Row(horizontalArrangement = Arrangement.) {
            Box(modifier = Modifier.cardDefault(Color.Magenta).)
            Box(modifier = Modifier.cardDefault(Color.Magenta).)
        }
    }
}
weight(3f)weight(4f)weight(6f)weight(1f)weight(1f)weight(2f)spacedBy(8.dp)spacedBy(4.dp)weight(2f)spacedBy(4.dp)padding(16.dp)spacedBy(16.dp)

Create a free account to access the full topic