0

I have a view with three linear layouts and listview.I want to scroll the entire view while scrolling the list.Is it possible? Scrollview not worked.Please help me .thanks in advance

layout.xml

<?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="match_parent"
    android:background="@color/white"
    android:orientation="vertical" >

        <LinearLayout
            android:layout_width="185dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="2dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/txt1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:singleLine="true"
                android:text=""
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/black" />
            <TextView
                android:id="@+id/txt2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:textColor="#9d9d97" />
          </LinearLayout>

   <LinearLayout
            android:layout_width="185dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="2dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/txt3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:textColor="#9d9d97" />
            <TextView
                android:id="@+id/txt4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:textColor="#9d9d97" />

   </LinearLayout>

  <LinearLayout
            android:layout_width="185dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="2dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/txt5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLength="30"
                android:textColor="#9d9d97"
                android:textSize="13sp" />
            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""
                android:textColor="#9d9d97" />

        </LinearLayout>

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:background="@color/white"
            android:cacheColorHint="@color/white"
            android:dividerHeight="1.0sp"
            android:fillViewport="true"
            android:longClickable="true" >
        </ListView>

</LinearLayout>
TheFlash
  • 5,997
  • 4
  • 41
  • 46
user1767260
  • 1,543
  • 8
  • 26
  • 51
  • @user1767260 post your xml. – TheFlash May 31 '13 at 05:40
  • @user1767260: ListView itself is a scrollable View so no its not the best practise to use ScrollView for a ListView (as a parent view). and keep in mind scroll view only works for one child view( you can have multiple childs (view) inside child view (layout) of ScrollView. – Mahaveer Muttha May 31 '13 at 06:04

1 Answers1

2

Putting ListView inside ScrollView is not a good idea.

Either make your three LinearLayouts headers like here: http://www.vogella.com/articles/AndroidListView/article.html#miscellaneous_headerfooter or make them part of the adapter using getViewTypeCount and getItemViewType and returning them from getView: getViewTypeCount and getItemViewType methods of ArrayAdapter.

Community
  • 1
  • 1
MaciejGórski
  • 22,187
  • 7
  • 70
  • 94