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
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.