Status Update
Comments
an...@google.com <an...@google.com> #2
Hello
Box {
Box(
Modifier
.clickable { println("clickable 1 clicked") }
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Green)
)
Box(
Modifier
.padding(top = 100.dp)
.clickable(enabled = false) { println("clickable 2 clicked") }
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Red.copy(alpha = 0.5f)))
}
Here we have two sibling clickable boxes. And the first one will not be clickable on their interception, the disabled clickable is still consuming exactly to not make something below it to be clickable. And we are leaning towards the idea disabled scrollable areas should behave the same. Can you share a real life example where it is not what you need?
an...@google.com <an...@google.com>
ma...@gmail.com <ma...@gmail.com> #3
We are attempting to achieve sort of reverse parallax effect, where background moves with user's finger, but foreground moves with a different velocity.
To achieve that, we set up two LazyRows one on top of another. We want user to be able to scroll the bottom one and then bottom one would programmatically scroll the top one.
lists could potentially have many items, so we do not want to use regular Row for this.
an...@google.com <an...@google.com>
an...@google.com <an...@google.com>
le...@google.com <le...@google.com>
le...@google.com <le...@google.com> #4
As Andrey explained, the way the pointer events navigate between sibling items is what determines the behavior you're seeing, so this is WAI. An alternative for your specific use case would be to use a Scrollable modifier at the parent Box to intercept the scroll events, and then dispatch them accordingly to each lazy list. Something like this:
val state1 = rememberLazyListState()
val state2 = rememberLazyListState()
val scrollState = rememberScrollableState{
state1.dispatchRawDelta(-it)
state2.dispatchRawDelta(-it/2)
it
}
Box(modifier = Modifier.scrollable(scrollState, orientation = Orientation.Horizontal)) {
LazyRow(state = state1, userScrollEnabled = false) {
items(20) {
Box(
Modifier
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Green))
}
}
LazyRow(modifier = Modifier.padding(top = 100.dp), state = state2, userScrollEnabled = false) {
items(20) {
Box(
Modifier
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Red.copy(alpha = 0.5f)))
}
}
}
Description
Here is a demo composable:
Box {
LazyRow() {
items(20) {
Box(
Modifier
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Green))
}
}
LazyRow(modifier = Modifier.padding(top = 100.dp), userScrollEnabled = false) {
items(20) {
Box(
Modifier
.size(200.dp, 200.dp)
.padding(end = 32.dp)
.background(Color.Red.copy(alpha = 0.5f)))
}
}
}
With compose 1.2.0-alpha07, you cannot scroll the top list by scrolling in the middle (where bottom list overlaps it), even though bottom list has scroll disabled.