简体   繁体   English

Jetpack compose Accompanist HorizontalPager 未检测到滑动

[英]Jetpack compose Accompanist HorizontalPager doesn't detect swipes

I have a HorizontalPager() in my screen and it doesn't detect swipes.我的屏幕上有一个HorizontalPager() ,它没有检测到滑动。 Just for test i created default HorizontalPager() via docs只是为了测试我通过文档创建了默认的HorizontalPager()

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我检查了HorizontalPager()是否有任何屏幕输入并添加了

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.所以检测到选项卡,这意味着寻呼机没有被另一个 UI 元素阻止。 But default swipes isn't works so.但是默认滑动是行不通的。 Elements size is hardcoded.元素大小是硬编码的。 Library ver — 0.23.1库版本 — 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 currentProfile.photos不是 null 并且大小 > 1

There was non-obvious problem.存在不明显的问题。 We have nested HorizontalPager like "Pager in Pager" + TabLayout.我们嵌套了 HorizontalPager,如“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.所以我的同事在顶级 HorizontalPager 中禁用了水平滚动输入,这就是为什么所有嵌套的 HorizontalPager 也被禁用的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jetpack Compose - 在 Accompanist HorizontalPager 中延迟加载数据 - Jetpack Compose - Lazy loading of data in Accompanist HorizontalPager Android 应用程序因 Jetpack Compose 的 Accompanist HorizontalPager 中的 NullPointerException 而崩溃 - Android app crash due to NullPointerException in Accompanist HorizontalPager for Jetpack Compose 伴奏者嵌套的 HorizontalPager 禁用父项中的滑动 - Accompanist Nested HorizontalPager disable swipes in parent 如何在 Jetpack compose 中检测 HorizontalPager 中的滑动? - How to detect swipe in HorizontalPager in Jetpack compose? 在 Jetpack Compose 的 HorizontalPager 中滚动阻力 - Resistance with scroll in HorizontalPager in Jetpack Compose SystemUIController 不会设置状态栏颜色 - Jetpack Compose Accompanist - SystemUIController won't set status bar color - Jetpack Compose Accompanist Jetpack Compose:如何检测 Horizo​​ntalPager 中的 TabRow 何时可见并调用 ViewModel 函数? - Jetpack Compose: How to detect when TabRow inside HorizontalPager is visible and call a ViewModel function? 如何在 Jetpack Compose 中禁用 HorizontalPager 的寻呼机 animation - How to disable pager animation of HorizontalPager in Jetpack Compose 带有 LazyColum 的 HorizontalPager 在另一个 LazyColum 中 - Jetpack Compose - HorizontalPager with LazyColum inside another LazyColum - Jetpack Compose 如何防止在 Jetpack Compose 中的 HorizontalPager 中滑动 - How to prevent swipe in HorizontalPager in Jetpack Compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM