1

I am having a xml file in which UI elements are arranged in the following sequence. The data I am parsing is being populated on the listView but the listView is not scrollable.Please help me

ImageView
TextView
imageView
ListView
imageView

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView_description"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:focusableInTouchMode="true"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView_now_playing"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:scaleType="fitXY" />



        <TextView
            android:id="@+id/textView_DailyLimit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageView_now_playing"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="2dp"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_below="@+id/button_PlayArea"
            android:layout_marginTop="20dp"
            android:background="#ffffff"
            android:orientation="vertical" >

            <ListView
                android:id="@+id/listViewEpisodes"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:cacheColorHint="#000000"
                android:divider="@android:color/black"
                android:dividerHeight="5dp"
                android:textColor="#000000" />
        </LinearLayout>

        <ImageView
            android:id="@+id/button_Characters"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayout1"
            android:layout_marginTop="20dp"
            android:scaleType="fitXY"
            android:src="@drawable/gallery" />

        <ImageView
            android:id="@+id/button_PlayArea"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView_DailyLimit"
            android:layout_marginTop="20dp"
            android:scaleType="fitXY" />
    </RelativeLayout>

</ScrollView>
onkar
  • 4,427
  • 10
  • 52
  • 89
  • if you want to scroll whole layout with listview then use header and footer view of listview. – Ketan Ahir Sep 27 '13 at 07:10
  • @Ketan can you please clear your answer, I didnot get it – onkar Sep 27 '13 at 07:11
  • I feel it is worth mentioning why you shouldn't put a ListView inside a ScrollView. 1) As @prateek pointed out is a UX problem. 2) Is a technical problem: a ScrollView allows its child to assume it has an infinite height (its content isn't bound by its own size since it can scroll). A strong advantage of a ListView is view recycling, which will not happen as the ListView will inflate the entire adapter since it thinks it has enough room to show them all. – FunkTheMonk Sep 27 '13 at 07:25

4 Answers4

2

You are making a big mistake here by placing the Listview inside Scrollview. Remove Scrollview and UserRelativeLayout as the Top parent and the Listview will scroll.

Also a UX suggestion is never ever use two scrollable items in side one another as user would never be able to know what has to be scrolled. And similarly you won't be able to recognize what is user trying to scroll.

Suggestion


You can do one thing. Just keep your TextView inside the Scrollview and below it keep your listview but don't make the whole layout scrollable. i.e. two elements can be scrolled but not the whole screen with scrollable elements.

Prateek
  • 3,923
  • 6
  • 41
  • 79
0

Never put a listView inside a scrollView. Never ever.

Watch his great video to know more abt listView

http://www.youtube.com/watch?v=wDBM6wVEO70

Gk'
  • 36
  • 5
0

ListView does not need inside the ScrollView to make it scrollable because ListView will be scrollable if the content is too long.

RussVirtuoso
  • 900
  • 1
  • 9
  • 20
0

You can put listview inside scrollview. See this https://stackoverflow.com/a/18354096/942224

and set this value of listview

yourListView.setExpanded(true);
Community
  • 1
  • 1
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75