user2150445 user2150445 - 4 years ago 170
Android Question

Android ScrollView set height for displayed content

I'm having a lot of trouble trying solve the issue of having a static height scrollable area within a layout. I have three long lists that need to be displayed on the same screen and it would be entirely impractical to display all of the entries sequentially because then if you want to skip a category you need to scroll past possibly hundreds of entries.

Assume I have a scroll view with a Linear Layout inside of it, I want this to take up say, 250dp height on the screen at max and be independently scrollable once populated with more entries than can fit in 250dp's space.

What I have now is:

android:id="@+id/XXXXXX" />

When populated, the scrollview and linearlayout just stretch as long as they needs to to fit the content and displays all of it instead of having a "window" of 250dp/px (any measurment would be nice) with the content scrollable within it.

I'm new to the android platform, so perhaps the answer is obvious and I just didn't understand the language, but any help would be greatly appreciated!
Thank you

Put a linearLayout outside of the ScrollView with the height.

Answer Source

What you need is a maxHeight. But since views do not support it, you have to use a workaround.

Check out this answer:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download