Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack Compose - Scrollable Column and clip to padding

I have a simple screen with scrollable vertical column. It contains some text and images.

 Column(
   modifier = Modifier
     .fillMaxWidth()
     .padding(16.dp)
     .verticalScroll(rememberScrollState()),
 ) {
      ...
   }

The content is scrollable but it clips to defined padding. Meaning when you scroll, you can see that overscroll shadow does not fill the entire screen, but it is bound to the padding. It looks really bad:

enter image description here

In XML world you would use android:clipToPadding="false" to "fill" the container. Is there equivalent of that in Compose?

like image 438
rafakob Avatar asked Sep 10 '25 10:09

rafakob


2 Answers

Got it, apparently order of modifier constraints matters, didn't know that. Just place padding as last one.

Column(
   modifier = Modifier
     .fillMaxWidth()
     .verticalScroll(rememberScrollState())
     .padding(16.dp),
 ) {
      ...
   }
like image 51
rafakob Avatar answered Sep 13 '25 15:09

rafakob


Instead of setting the padding via modifier to the whole view, set the padding only for the content:

    LazyColumn(
        modifier = Modifier.fillMaxWidth(),
        contentPadding = PaddingValues(horizontal = 16.dp)
    ) {
       ...
    }
like image 32
Tobias Avatar answered Sep 13 '25 14:09

Tobias