2

How does Android think about ScrollViews?

I come from webdev background, so that is my paradigm for implementing a scrolling element.

Yet on Android, official tutorials and docs say, I should use height="wrap_content" for the ScrollView. But why?

From my understanding(webdev), ScrollView should be the container, in which it's content scrolls. Meaning ScrollView being the height restriction (therefore match_parent) and it's content should be higher than that (therefore scrolling).

If I set ScrollView height to wrap_content, and Android would actually honor that... it should not be scrollable (by my webdev paradigm) (unless Android does not add additional layout containers (outside those defined in layout file).

So how is it done?

EvilTak
  • 7,091
  • 27
  • 36
Lukáš Řádek
  • 1,273
  • 1
  • 11
  • 23

1 Answers1

0

A view group that allows the view hierarchy placed within it to be scrolled. Scroll view may have only one direct child placed within it. To add multiple views within the scroll view, make the direct child you add a view group, for example LinearLayout, and place additional views within that LinearLayout.

Here is a Link that helps you to know more about it

https://developer.android.com/reference/android/widget/ScrollView

and also here

https://www.javatpoint.com/android-scrollview-vertical

Arbaz Pirwani
  • 935
  • 7
  • 22