I have a Linearlayout and I want to make it scrollable without using ScrollView. Is it possible. Any suggestions will be appreciated. Here's the detail: If I wrap the LinearLayout using ScrollView, it is ok but when I used a ListView inside LinearLayout(because it is my clients requirement), it said do not use ListView inside ScrollView. I have to show 50 product list using ListView and I have to put this ListView inside LinearLayout and at the same time whole layout will be scrollable. Is it possible. Here is the skeleton:
<LinearLayout>
<RelativeLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<TextView>
</LinearLayout>
<LinearLayout>
<ListView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Important: See the ListView where I want to add 50 list item. So how can I make this total LinearLayout scrollable.
Actually after doing some research, I come up with a solution for this problem:
At first I want to explain the problem in a very simple way.
How to solve that?
ListView is scrollable inherently so we can add header and footer in the ListView. As a conclusion:
If you are only using a listview inside a linear layout, then you don't need to use scrollview.Because ListView is scrollable by default.But if you have other components as well then you can separate those in another scrollview.Make sure that ScrollView only uses one direct child layout. Below is a sample code.