Reputation: 1305
I have made a gridview and listview inside a LinearLayout. data that display is dynamic. gridview fill the 80% of the screen height.and listview have only 20% of screen height and in it items are scrollable but due to availability of screen height listview display only 2 items at a time..
now i want parent of listview and gridview is scrollable but gridview and listview are not so that list view can show more than 2 items at a time.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical" >
<include layout="@layout/app_headerview_imageview_textview" />
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:listSelector="@null"
android:numColumns="3"
android:layout_weight="1" >
</GridView>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#112F51"
android:orientation="horizontal"
android:padding="20dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/diagnose_button_selector"
android:text="Auto Diagnose"
android:textColor="#ffffff"
android:textSize="@dimen/small_text_size"
android:padding="@dimen/padding_medium"/>
<View
android:layout_width="0dip"
android:layout_height="1dip"
android:layout_weight=".2" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/diagnose_button_selector"
android:text="Diagnose Now"
android:textColor="#ffffff"
android:textSize="@dimen/small_text_size"
android:padding="@dimen/padding_medium" />
</LinearLayout>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E6E6E6"
android:orientation="vertical" >
<include layout="@layout/bottom_action_bar" />
</LinearLayout>
Upvotes: 0
Views: 1114
Reputation: 1984
A scollview should only have one direct child.
You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.
If you want to have more of the listview available on the screen, giving the fact that gridview is also scrollable, you should use the weight property for both children of the LinearLayout so that they take up similar amounts of space on the screen
Upvotes: 1