使用SnapFlingBehavior的Im
https://developer.android.com/vis/kotlin/androidx/compose/gestures/snapping/SnapFlingBehavior
该文稿作为更换Chris Banes snapper图书馆()提供。
在Snapper图书馆,我们能够通过这样做获得目前申请的立场。
snapperLayoutInfo. CurrentItem?
如何利用这一新版本来编制目前申请的项目索引。
使用SnapFlingBehavior的Im
https://developer.android.com/vis/kotlin/androidx/compose/gestures/snapping/SnapFlingBehavior
该文稿作为更换Chris Banes snapper图书馆()提供。
在Snapper图书馆,我们能够通过这样做获得目前申请的立场。
snapperLayoutInfo. CurrentItem?
如何利用这一新版本来编制目前申请的项目索引。
The SnapFlingBehavior
itself knows no current item and is usually just provided to the scrollable
modifier.
The composable that this scrollable
modifier is applied to must understand the concept of a current item, if this is something that you need.
堆肥框架提供内部处理所有这些问题的箱外堆肥,如<编码>Pager和DatePicker
。
更通用的<代码>LazyList和LazyGrid
,但可以滚动(因此,snapflingable),但它们对当前项目没有任何概念。 名单上所列国家的财产如下:firstVisibleItemIndex
。 然而,在使用默认的<代码>SnapFlingBehavior(该编码可向观察中心发送)时,清单中的第一个项目往往只部分可见一斑。 您可以将SnapFlingBehavior定制成像,使第一个项目始终见到。 您必须为此建立自己的<代码>SnapLayoutInfoProvider(可能具有以下功能:<代码>SnapLayoutInfoProvider(LazyListState, SnapPositionInLayout),因此,您仅需要提供一种定制的<代码>SnapPositionInLayout。
如果您使用某种其他代用品(SnapFlingBehavior
),则你必须确保这一代用品本身支持当前项目
你们可以这样作:
@Composable
fun rememberSnapFlingSelectedIndex(listState: LazyListState) = remember {
derivedStateOf {
with(listState) {
val itemsOnScreen = layoutInfo.visibleItemsInfo.size.takeIf { it != 0 } ?: 1
when {
!canScrollBackward -> firstVisibleItemIndex
!canScrollForward -> firstVisibleItemIndex + itemsOnScreen - 1
else -> firstVisibleItemIndex + itemsOnScreen.div(2)
// Or you can write your own conditions to determine item position
// ...
}
}
}
}
I know I can change the state with mutableStateListOf in Code B. Can I use MutableStateFlow(mutableListOf<Int>()) launch a Flow collect in Code A? If not, is there a similar Flow function just ...
I m running a Ktor server with a PostgreSQL database and just set up the JetBrains Exposed ORM framework with HikariCP for connection pooling (per the recommendation in the Ktor documentation). My ...
I am trying to create boardgamegeek APIs based app in AndroidStudio, however from unknown reason I m getting my database created with no columns. Here s Logical log: (1) no such table: games in "...
I m not exactly sure why this is happening but I have an idea. I m not sure what to do about it though. I ve searched the internet but haven t gotten an exact answer. Here is an error that might help. ...
我想照相机屏幕上的一个具体区域。
I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...
我正在学习 Android 开发中的 Jetpack compose。 有时候, 我使用 MaterialTheme.colors 和 MaterialTheme.colorScheme,因为其中一个会显示红色。 例如, Surface( color = MaterialTheme....
I am trying to return an object whenever a new object of a class is being created. I have tried using anyConstructed with a spyk or even mockk object of PredictionCheckFunction every { anyConstructed&...