-7

Scrollview not working in android phone

<ScrollView android:id="@+id/scrlListView"
            android:layout_width="match_parent"  
            android:layout_marginTop="5sp"                 
            android:layout_height="213dp">                                  
    <LinearLayout android:id="@+id/linrListView"  
                  android:layout_width="match_parent" 
                  android:layout_height="match_parent">
        <ListView android:id="@+id/listcontact"                         
                  android:layout_width="match_parent" 
                  android:divider="@null"
                  android:dividerHeight="2dp" 
                  android:scrollbars="vertical"
                  android:fastScrollEnabled="true"
                  android:layout_height="281dp"
                  android:cacheColorHint="#00000000">
        </ListView>
    </LinearLayout>
</ScrollView>

Whats the problem in this code?

Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
Revathi
  • 307
  • 6
  • 18

4 Answers4

1

A ListView will scroll itself inside its bounds if it needs to. If you haven't anything else inside the ScrollView, it is unneeded.

If you have more stuff not shown in your posted layout, the user will have to do a scroll gesture on something that is contained in the ScrollView that isn't the ListView, otherwise the ListView will consume the scroll gesture and it won't get passed to the ScrollView.

You can override this behaviour if you really want, but you may not need to if you only have the ListView.

FunkTheMonk
  • 10,908
  • 1
  • 31
  • 37
1

In normal situation you can not put a listView in a scrollView. But You can do it by a trick. find your solution in this link.

Community
  • 1
  • 1
Bob
  • 22,810
  • 38
  • 143
  • 225
0

Can you give me the log?

Also try using layout_height and width only with fill_parent or wrap_content and use the max_width and height.

Klaasvaak
  • 5,634
  • 15
  • 45
  • 68
0

The problem is that you're using a ListView inside of a ScrollView. The ScrollView has the size of the screen and it handles the scrolling events so your list view never receives any scroll events

DallaRosa
  • 5,737
  • 2
  • 35
  • 53