someguy590
someguy590

Reputation: 13

HorizontalPager overscroll effect only shows on half of the screen

When using HorizontalPager, trying to swipe past the first or last page will show the overscroll effect to indicate there are no more pages to view, but the visual effect only covers half the screen regardless if swiping from the top half or bottom half of the screen.

If swiping right pass the first page, the effect only covers the bottom half of the screen.

If swiping left pass the last page, the effect only overs the top half of the screen.

Page 1 (of 2) Swiping right overscroll effect apears only on bottom half of screen Page 2 (of 2) Swiping left overscroll effect apears only on top half of screen

Using HorizontalPager from androidx.compose.foundation:foundation:1.7.5

VerticalPager does not show any of these problems.

Code is pretty much copy pasted from the basic HorizontalPager sample from the Google docs https://developer.android.com/develop/ui/compose/layouts/pager#horizontalpager

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            HorizontalPager(
                state = rememberPagerState(pageCount = { 2 }),
                modifier = Modifier
                    .fillMaxSize()
                    .border(5.dp, Color.Blue)
            ) { page ->
                Text(
                    text = "Page: $page",
                )
            }
        }
    }
}

Upvotes: 1

Views: 50

Answers (1)

tyg
tyg

Reputation: 15579

This seems to be a bug that is fixed in 1.8.0.

As of the time of writing that version is still in alpha so you would need to either wait for the stable release or switch to the alpha BOM instead of the stable BOM:

androidx.compose:compose-bom-alpha:2024.11.00

Upvotes: 1

Related Questions