1

I have created one scroll view with two list Fragments here is the code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/blue_shade_top_gainers_and_loosers"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingBottom="1dip"
        android:paddingLeft="1dip"
        android:paddingRight="1dip"
        android:paddingTop="2dip" >

        <fragment
            android:id="@+id/header_fragment"
            android:name="com.lk.ignitionit.cse.util.HeaderFragmentActivity"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView13"
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >

        <RelativeLayout
            android:id="@+id/rl_top"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="1dip"
            android:layout_marginLeft="1dip"
            android:layout_marginRight="1dip"
            android:layout_marginTop="1dip"
             >

            <LinearLayout
                android:id="@+id/headg"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scrollbars="vertical" >

                <include layout="@layout/top_gainer_header" />
            </LinearLayout>

            <fragment
                android:id="@+id/gain"
                android:name="com.lk.ignitionit.cse.application.TopGainersFragmentActivity"
                android:layout_width="match_parent"
                **android:layout_height="wrap_content"**
                android:layout_below="@+id/headg" />

            <LinearLayout
                android:id="@+id/headl"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/gain" >

                <include layout="@layout/top_loosers_header" />
            </LinearLayout>

            <fragment
                android:name="com.lk.ignitionit.cse.application.TopLoosersFragmantActivity"
                android:layout_width="match_parent"
                **android:layout_height="wrap_content"**
                android:layout_below="@+id/headl" />
        </RelativeLayout>
    </ScrollView>

</LinearLayout>

but the out put is not show the entire list

then i change the fragment layout height into 240dip instead of "wrap_content" now it's enough to show entire list. but the thing is, those data is dynamic and each list fragment have 10 list items.so i can't predict the the fragment height. if the names are long, this height is not enough.

so i need to set fragment height as wrap_content and scroll able. how can i do this?

user1688181
  • 496
  • 1
  • 10
  • 27

1 Answers1

0

There are several questions already on SO for this. There seems to be no perfect answer, but there are several pointers. Please do a search for them. One example:

Scrolling with multiple listviews for android

Community
  • 1
  • 1
Aviral
  • 1,141
  • 1
  • 10
  • 16
  • i could solve this using fixed height.but what will happen on different screens.is it best practice? – user1688181 Nov 05 '12 at 10:23
  • There are a lot of options such as using and expandable list, converting to one list with different headers, etc. Use what is most suited to your needs... – Aviral Nov 05 '12 at 10:45