3

Some similar questions were asked but none with a definitive answer for this issue . While there are few elements in the stack , i want to disable the scroll in scrollView (which is the natural behaviour in android) .

I can prevent scroll with SrcollView{View}.disabled(true)

However, all interactions with subviews are lost : not Tap,no Drag ... Even simple ideas would be welcome .

9
  • I must be missing part of the equation here -- if you don't want the user to be able to scroll, why put it in a ScrollView? Is it because you want to toggle the scrolling on and off? Commented Apr 9, 2021 at 19:58
  • 1
    yes, in a full contentView space when ther are for example 2 elements in the list , i want the user to be able to interact with those elements but not scroll those elements up and down when there are nothing more to show . If list has for example 20 elements , it make sense to scroll . I would decide when to make it scroll or not (basically when more elements than the screen size ) Commented Apr 9, 2021 at 20:05
  • you can code in this way that scrollView would not used in some condition, that would be more doable Commented Apr 9, 2021 at 20:12
  • 1
    Thank you SwiftPunk, i thought about this at the last solution use dynamically ScrollView only if more than 20 elements for example .Would be doable but not too reactive i guess for dynamic lists. It is just that i m suprised i couldn t find a more elegant solution so far anywhere . Thank you once more Commented Apr 9, 2021 at 20:23
  • Does this answer your question stackoverflow.com/a/60910593/12299030? Commented Apr 10, 2021 at 15:43

1 Answer 1

1
ScrollView {
    //
}
.scrollDisabled(true)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.