1

I have this structure

<LinearLayout android:id="@+id/1"> <LinearLayout android:id="@+id/2" /> <LinearLayout android:id="@+id/3"> <ListView android:id="@android:id/list" /> </LinearLayout> </LinearLayout> 

And I populate the ListView with some data. Well my problem is that the ListView becomes scrollable (while the LinearLayout number 1 fits the screen without scrolling), but what I want is this View to become full height and that the LinearLayout with id=1 becomes scrollable.

Inside ListView number 2 I have some TextViews, etc.

1
  • did you found solution for this? Commented Dec 12, 2015 at 9:24

2 Answers 2

1

ListView's are scrollable by default if when the content is more than its display area.

However, LinearLayout would need to have a ScrollView in order to scroll.

Red Alert - You cannot use ScrollView and ListView together. You will end up seeing un-expected.

Alternate Solution: Prioritize what is more important to you, if scrolling the entire screen then add a ScrollView (provided your ListView items are static) else I will to wait to hear a good solution on this one. :)

Sign up to request clarification or add additional context in comments.

6 Comments

I have a "card" with a profile basic information and then a list of items related to this profile. If the list becomes very big, to have a small scrollable LinearLayout will become uncomfortable. Let's see if I find a solution.
As visible from your layout, the ListView lies to the bottom (so the layout may not scroll beyond it) and as you said its items can grow larger, so you should go with ListView till you get a solution. Do let me know as well so that even I can use it. :)
I'll do so! I'm thinking, I could even want to add another "card" with some information under the ListView, but by now it would make the ListView even smaller...
Adding a new card will make your layout more complex. Why dont you use tabs to represent cards? how many cards do you have at a time? or can you post an image as to what you want the layout to look like?
I didn't think of that approach, and could be a good solution! Btw I could do it with a ScrollView that encapsulates everything and with a method that calculates the height for the ListView and forces it through listView.setLayoutParams(). I know that I'm not supposed to use ScrollView and ListView, thus I'm changing it.
|
0

Add ScrollView for ListView. ScrollView will work for only one child view, so you have to add like this

LinearLayout

LinearLayout LinearLayout

ScrollView

ListView...../ListView

/ScrollView

/LinearLayout

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.