Status Update
Comments
jn...@google.com <jn...@google.com> #2
Currently if a developer does not provide vertical contentPadding of sufficient size then one or more list items can not be scrolled in to the middle of a ScalingLazyColumn viewport. This combined with the scaling characteristics of the ScalingLazyList component results in the first and last items in the list often being partly obscured (on a round device - this it the most common type of device) and being scaled down and partly transparent.
As a result developers will typically provide vertical content padding to provide enough space above the first and below the last list items to make sure that they can be scrolled into view. However determining how much content padding to provide can be difficult as the size of the list items is not known ahead of time and the size of the device and component on the screen is not known ahead of time either.
jn...@google.com <jn...@google.com> #3
The planned approach is to provide a new property autoCenterable: Boolean = true
which will ensure that that there is enough space before the first and after the last list component so that they can be centered in the viewport. The space added will be additive to any vertical contentPadding that the developer might also provide. If the autoCenterable = false then the developer is responsible for making sure that their list is laid out in such a way that the user can access all of the contents.
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit 50c6882d8a5fa424793bb0d7cdb6e1c7480d58c8
Author: jnichol <jnichol@google.com>
Date: Mon Jan 17 15:08:52 2022
ScalingLazyColumn.kt - add autoCentering property
Add a new property autoCentering: Boolean defaulted to true to ScalingLazyColumn.kt that will add space before the first and after the last list items in order to ensure that they can be scrolled to the center of the viewport. This avoids the need for a developer to try and work out how much contentPadding might be required on different sizes of wearables/lists so that all items can be scrolled to the center to be properly viewed.
RelNote: "We have added a new property autoCentering to the ScalingLazyColumn. When true (the default) this will ensure that all items including the first and last can be scrolled so that they are visible in the center of the lists viewport. Note that if using auto-centering you will probably want to set vertical content padding to 0.dp. If both autoCentering and vertical content padding are provided then they will both result in addition space being available before the first and after the last list items allowing them to be scrolled even further."
Test: ./gradlew :wear:compose:compose-material:connectedCheck --info --daemon
Bug: 214922490
Change-Id: I2a2827ad79ea6cf1cb5d9a623b600417def9cc2f
M wear/compose/compose-material/benchmark/src/androidTest/java/androidx/wear/compose/material/benchmark/ScalingLazyColumnBenchmark.kt
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/ScalingLazyListState.kt
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/ScalingLazyColumn.kt
M wear/compose/compose-material/api/current.txt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyColumnIndexedTest.kt
M wear/compose/compose-material/api/restricted_current.txt
M wear/compose/compose-material/api/public_plus_experimental_current.txt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyListLayoutInfoTest.kt
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/ScalingLazyColumnMeasure.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/PositionIndicatorTest.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyColumnTest.kt
Description
Based on feedback from developers there is a need to provide support to make it easy to ensure that all list items can be placed in the center of a ScalingLazyColumn viewport. That is that if they have an offset of 0 they would be placed centrally without the developer needing to try and work out how much vertical contentPadding to provide.