When using `AnimatedVisibility` how can I make th...
# compose
d
When using
AnimatedVisibility
how can I make the container scroll to show the item being expanded? (say I'm at the end of the scroll and there's an expandable item
👀 1
c
Got an example to show what you want to do? I don't understand your message.
z
Are you saying that scrollable containers aren’t adjusting when an animated visibility child adjusts its size? If so, I would file a bug.
a
I'm pretty sure we would treat that kind of bug as a request for sample code rather than a request for default behavior. "Do what I mean" for automatic scrolling of containers as contents change is highly context dependent
That said, I agree that having those examples available and being more or less happy with the amount/complexity of code required to accomplish it is important and it's worth a filed issue
d
Copy code
Column(Modifier.verticalScroll()) {
  // ....
  Row(Modifier.fillMaxWidth()) {
      Text("Expandable section")
      Spacer(Modifier.weight(1f))
      IconButton() // toggle expansion
  }
  AnimatedVisibility(
  ) {
     StuffOnlyVisibleWhenExpanded()
  }
}
when this is at the end of the scrollable area (not visible) and it becomes visible the scroll doesn't budge. So I'm asking what's the simpliest way to make it "scroll" to show. And I totally agree that it should not automatically scroll but I should be able to control it 🙂
I'll open a bug tonight
👍 1
a
I imagine that some upcoming features to request parent containers to scroll/pan to make specific content visible may make the answer to this a lot simpler. It also comes up in cases where you focus a text field and the keyboard opens.
d
Here, sorry for taking so long: https://issuetracker.google.com/issues/195318428
👍 1
144 Views