0

I want to stick item at bottom of screen. I did this in larger screen without any problem with the help of this stack overflow. Now I want to stick item in smaller screen, but above stack overflow answer is not working in smaller screen.

@Preview(showBackground = true, widthDp = 240, heightDp = 432)
@Composable
fun PreviewCompose() {
    Theme {
        Column(
            Modifier
                .fillMaxSize()
                .verticalScroll(rememberScrollState()),
            verticalArrangement = Arrangement.SpaceBetween

        ) {
            Text(
                "Parent 1",
                modifier = Modifier
                    .background(Color(0xffF44336)),
                color = Color.White,
                fontSize = 75.sp
            )
            Text(
                "Parent 2",
                modifier = Modifier
                    .background(Color(0xffF44336)),
                color = Color.White,
                fontSize = 75.sp
            )
            Text(
                "Parent 3",
                modifier = Modifier
                    .background(Color(0xffF44336)),
                color = Color.White,
                fontSize = 75.sp
            )
            Spacer(modifier = Modifier.weight(1f))
            Column() {
                Text(
                    "Child 1",
                    modifier = Modifier
                        .background(Color(0xffF44336)),
                    color = Color.White
                )
                Text(
                    "Child 2",
                    modifier = Modifier
                        .background(Color(0xffF44336)),
                    color = Color.White
                )
            }
        }
    }
}

Actual Output

I am adding my youtube link to understand.

Expected Output

enter image description here

Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127

1 Answers1

2

You can use something like:

Column(
    verticalArrangement = Arrangement.SpaceBetween
){
        Column(
            Modifier
                .verticalScroll(rememberScrollState())
                .weight(1f)                    
        ) {
           //Parent1/2/3
        }

        Column() {
            //Child 1/2
        }

}

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841