androidandroid-jetpack-composecomposableandroid-compose-layout

How to individually/separately align child composables inside a Row?


I'm new in jetpack compose and I'm trying to do a simple thing that I can't achieve it.

That I want to do is in the same row align one component, in this case a surface, at the start and the other one, the column, at the end of the row.

How can get this?

I'm trying this but it doesn't work:

Row(Modifier.padding(top = 24.dp)
        .fillMaxWidth()) {
        Surface(
            modifier = Modifier.size(70.dp),
            shape = RectangleShape,
            color = MaterialTheme.colors.onSurface.copy(alpha = 0.2f)
        ) {
            // Image goes here
        }

        Column(modifier = Modifier.size(70.dp)) {
            Text("Total",
                fontSize = 12.sp,
                color = AppGreyDark,
                modifier = Modifier.padding(end = 16.dp))

            Text("12,99 €",
                fontSize = 18.sp,
                color = AppBlackDark,
                modifier = Modifier.padding(top = 4.dp))
        }
    }

Solution

  • You can apply in the Row the Arrangement.SpaceBetween.

    Row(
        modifier = Modifier
          .padding(top = 24.dp)
          .fillMaxWidth(),
        horizontalArrangement  =  Arrangement.SpaceBetween) {
           Surface()
           Column()
    }
    

    enter image description here