androidscrollandroid-jetpack-compose

How to fixate views to off-screen part of the vertically-scrollable compose screen?


I have a vertically scrollable compose screen, and want to make certain sub-components (outlined black) fill the visible part of the screen and the rest (outlined blue) only visible after scroll regardless of the screen size.

In the drawing below, the black part should be the initially visible part and the blue part is only visible after scrolling down. I want to achieve that the black components are fixated to visible part regardless of the screen size and the blue components fixated always to the off-screen part and only visible after scrolling down.


Solution

  • Try something like this using LazyColumn:

    LazyColumn(modifier = Modifier
        .fillMaxSize()) {
        item {
            Column(modifier = Modifier.fillParentMaxSize()) {
                //screen content
            }
        }
        item {
            //scroll content
        }
    }