Fixed
Status Update
Comments
jn...@google.com <jn...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 6244459214bb2b9554333957f4cf5afa022c0058
Author: John Nichol <jnichol@google.com>
Date: Tue Feb 01 15:10:11 2022
Change the default initialCenterItemIndex of the ScalingLazyListState from 0->1.
Change the default list item that we place in the center of the ScalingLazyColumn viewport from index 0->1. This gives a more natural default set up for most lists, especially if they have a list header item as the first item.
RelNote: "We have changed the default initialCenterItemIndex for the ScalingLazyListState from 0->1. This means that unless overridden on state construction with ScalingLazyListState.rememberScalingLazyListState(initialCenterItemIndex = <value>) then the 2nd list item (index == 1) will be placed in the center of the viewport at initialization and the 1st (index == 0) item will be placed before it. This allows for a better default visual effect out of the box as most of viewport will be filled with list items."
Bug: 217344252
Test: ./gradlew wear:compose:compose-material:connectedCheck --info --daemon
Change-Id: I0c62304ff98c3233e48f38a3641ef856491b5838
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/ScalingLazyListState.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyColumnIndexedTest.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyListLayoutInfoTest.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
https://android-review.googlesource.com/1966578
Branch: androidx-main
commit 6244459214bb2b9554333957f4cf5afa022c0058
Author: John Nichol <jnichol@google.com>
Date: Tue Feb 01 15:10:11 2022
Change the default initialCenterItemIndex of the ScalingLazyListState from 0->1.
Change the default list item that we place in the center of the ScalingLazyColumn viewport from index 0->1. This gives a more natural default set up for most lists, especially if they have a list header item as the first item.
RelNote: "We have changed the default initialCenterItemIndex for the ScalingLazyListState from 0->1. This means that unless overridden on state construction with ScalingLazyListState.rememberScalingLazyListState(initialCenterItemIndex = <value>) then the 2nd list item (index == 1) will be placed in the center of the viewport at initialization and the 1st (index == 0) item will be placed before it. This allows for a better default visual effect out of the box as most of viewport will be filled with list items."
Bug: 217344252
Test: ./gradlew wear:compose:compose-material:connectedCheck --info --daemon
Change-Id: I0c62304ff98c3233e48f38a3641ef856491b5838
M wear/compose/compose-material/src/commonMain/kotlin/androidx/wear/compose/material/ScalingLazyListState.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyColumnIndexedTest.kt
M wear/compose/compose-material/src/androidAndroidTest/kotlin/androidx/wear/compose/material/ScalingLazyListLayoutInfoTest.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
Talking with the UX team about the best defaults to apply for a
ScalingLazyColumnListState
we have agreed to change the defaultinitialCenterItemIndex
from 0 to 1. This means that by default a ScalingLazyColumn will have it 2nd item (index == 1) in the middle of the screen with it's first item (index == 0) above it and visible.This behaviour can easily be overridden by developers by passing
initialCenterItemIndex == 0
torememberScalingLazyListState()
.If there are insufficient items in the list to position item 1 in the center then the actual center item and offset will correctly report the resulting values in the state.