Sunday, 11 August 2013

Multiple listView in linear layout Android

Multiple listView in linear layout Android

I have 4 listViews that are being set dynamically. My content exceeds the
screen size, so I am unable to show all content.
Here is what it looks like in a linearLayout Keep in mind, the
"banner"/image will change accordingly to the list. There should be 4. For
some reason the bottom list only, as you can see can scroll. (not what I
want)

And here is the xml
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvSponsors"
android:layout_gravity="left|center_vertical"/>
<!--Gold-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvGold"
android:layout_gravity="left|center_vertical"/>
<!--Silver-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvSilver"
android:layout_gravity="left|center_vertical"/>
<!--Bronze-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvBronze"
android:layout_gravity="left|center_vertical"/>
</LinearLayout>
And if I set the root view to scrollView I get this;

And my xml for the scroll view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/chainlink">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvSponsors"
android:layout_gravity="left|center_vertical"/>
<!--Gold-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvGold"
android:layout_gravity="left|center_vertical"/>
<!--Silver-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvSilver"
android:layout_gravity="left|center_vertical"/>
<!--Bronze-->
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/platinumhead"/>
<ListView
android:layout_margin="8sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvBronze"
android:layout_gravity="left|center_vertical"/>
</LinearLayout>
</ScrollView>
My content is obviously too big for the screen so I will need a ScrollView
that would scroll the entire page simultaneously. How do I fix my xml or
java to do this?

No comments:

Post a Comment