4

I have a HorizontalPager() in my screen and it doesn't detect swipes. Just for test i created default HorizontalPager() via docs

Just pasted in my screen

HorizontalPager(count = 10) { page ->
    Text(
        text = "Page: $page",
        modifier = Modifier.fillMaxWidth()
    )
}

And it also doesnt't swipes. I have checked if HorizontalPager() any screen input and added

Modifier
.pointerInput(Unit) {
                detectTapGestures { Log.d("Screen Input", "Pager tap") }
            }

So the tabs were detected, what mean that pager isn't blocked by another UI element. But default swipes isn't works so. Elements size is hardcoded. Library ver — 0.23.1

UPDATE

Part of real code

        Column(
            modifier = Modifier
                .fillMaxSize()
                .background(Colors.Background.light)
                .verticalScroll(scrollState)
        ) {
            val itemWidth = LocalConfiguration.current.screenWidthDp
            val itemHeight = itemWidth * 1.42
            val imageCornerRadiusInPx =
                with(LocalDensity.current) { (itemWidth / 2f).dp.toPx() }
            
            HorizontalPager(
                count = currentProfile.photos.size
            ) { page ->
                currentProfile?.photos?.get(page)?.url.let { url ->
                    Box(
                        contentAlignment = Alignment.TopEnd
                    ) {
                        Image(
                            modifier = Modifier
                                .fillMaxWidth()
                                .height(itemHeight.dp),
                            painter = rememberImagePainter(
                                data = url,
                                builder = {
                                    transformations(
                                        RoundedCornersTransformation(
                                            bottomLeft = imageCornerRadiusInPx,
                                            bottomRight = imageCornerRadiusInPx,
                                        )
                                    )
                                }
                            ),
                            contentDescription = null,
                        )
        }
    }
}

currentProfile.photos is not null and have size > 1

dbuzin
  • 195
  • 2
  • 13
  • Try reproducing it in a newly created Compose project. – Phil Dukhov Apr 08 '22 at 11:26
  • @PylypDukhov in new clean project it works correctly. Also updated the question – dbuzin Apr 08 '22 at 11:44
  • I don't see anything that can cause such problem, try moving `HorizontalPager` up in your view tree until you find the parent which prevents it from scrolling. – Phil Dukhov Apr 08 '22 at 12:10
  • @PylypDukhov already tried to place pager in the top of ```@Composable``` tree, but it still doesn't work – dbuzin Apr 08 '22 at 12:33
  • So this is the only content of `setContent` and still doesn't work? I don't know what build configuration can cause that, try replacing your configuration files(starting with the manifest file, then gradle) one by one from the newly created project to see which one cases the problem. – Phil Dukhov Apr 08 '22 at 12:41

1 Answers1

0

There was non-obvious problem. We have nested HorizontalPager like "Pager in Pager" + TabLayout. So my colleague has disabled horizontal scroll input in top-level HorizontalPager, that is why all nested HorizontalPager were disabled too.

dbuzin
  • 195
  • 2
  • 13