Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Fragments Ingredients and Directions Becoming Scrollable

vicente lee
vicente lee
6,271 Points

ScrollView children width and height

The warning that Ben mentions states: ScrollView children must set their layout_width or layout_height attributes to wrap_content rather than fill_parent or match_parent in the scrolling dimension.

Why is this and why do we just need to change height to wrap_content and not both to wrap_content?

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

A ScrollView is supposed to fit a child bigger than itself and scroll vertically to let you see the whole thing. Setting the height of the content inside to match_parent, i.e., the height of the ScollView, defeats the purpose. match_parent for width is ok, and let's the child know how wide it can be. It the project, it lets the instructions/direction word wrap to the fixed width and only have to scroll vertically.