Yingding Wang
08/05/2022, 10:02 AMval state: ScalingLazyListState = rememberScalingLazyListState()
Scaffold (
vignette = { Vignette(vignettePosition = VignettePosition.TopAndBottom) },
positionIndicator = { PositionIndicator(scalingLazyListState = state) }
) {
ScalingLazyColumn (
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
state = state,
anchorType = ScalingLazyListAnchorType.ItemCenter,
) {...
After I set the ScalingLazyListState(), and autoCentering both to (0, 0), the first element is shown correctly.
val state: ScalingLazyListState = rememberScalingLazyListState(
initialCenterItemIndex = 0,
initialCenterItemScrollOffset = 0
)
Scaffold (
vignette = { Vignette(vignettePosition = VignettePosition.TopAndBottom) },
positionIndicator = { PositionIndicator(scalingLazyListState = state) }
) {
ScalingLazyColumn (
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
state = state,
anchorType = ScalingLazyListAnchorType.ItemCenter,
autoCentering = AutoCenteringParams(itemIndex = 0, itemOffset = 0)
) {...
And set to (1, 0) as the both defaults are, doesn’t work. (0, 0) seems to be the only working combi. I think this issue was also present in horologist (https://github.com/google/horologist/issues/245).
Any thoughts on this are appreciated.
Update: It is worth to mention that my items are two full screen elements. After I scrolled the screen, the code behaved like I had set (0, 0).
item {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(text = "Hello World!")
}
}
ScalingLazyListState
and autoCentering
of ScalingLazyColumn
are not the same, the code doesn’t work.
val listState: ScalingLazyListState = rememberScalingLazyListState(
initialCenterItemIndex = 0,
initialCenterItemScrollOffset = 30
)
...
ScalingLazyColumn(
autoCentering = AutoCenteringParams(itemIndex = 0, itemOffset = 0)
The construct of state and autoCentering is somehow confusing.John Nichol
08/05/2022, 12:09 PM@Composable
fun SLCLargeItemsNotVisible() {
val state = rememberScalingLazyListState()
ScalingLazyColumn(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
state = state,
autoCentering = AutoCenteringParams()
) {
items(4) {
Card(
onClick = {},
modifier = Modifier.height(300.dp),
) {
Box(modifier = Modifier
.fillMaxSize()
.background(Color.Blue))
}
}
}
}
Yingding Wang
08/05/2022, 2:40 PM@Composable
fun fullScreenImage() {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Image(
painter= painterResource(R.drawable.watch_preview_circular_384),
contentDescription = "Yellow fullscreen"
)
}
}
@Composable
fun fullScreenText() {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(text = "Hello World!")
}
}
will open an issue report.John Nichol
08/06/2022, 9:32 AMImages
I don't have any immediate ideas why it would matter what the type of content is - but with a repro case I am sure we will soon get to the bottom of it.Yingding Wang
08/09/2022, 11:43 AMJohn Nichol
08/09/2022, 12:06 PM