0

I have a data set and I need to show them using ListView and TableLayout in same xml file.As both ListView and TableLayout are much longer,I decide to use scrollView. I knew that android scrollview can only have one child. So I Coded as follows.

  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="8">

<LinearLayout
    android:id="@+id/showClaim_layout2"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">



    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/claimList"
        android:layout_margin="5dp">
    </ListView>

    <TableLayout
        android:id="@+id/showClaimTable"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFEBCD"
        android:layout_margin="5dp"
        android:shrinkColumns="0">

    </TableLayout>

</LinearLayout>

</ScrollView>

When I run the program it's ok. I mean page is scrolling. But it doesn't work as I expected!I need to show all the list element and after end of the list, tableLayout must be show.If the screen size is not enough then we can scroll the page and see the data. In here ListView does not show all elements of the List and TableLayout show all tableRaws inside ScrollView.

Can anyone tell me that where I got wrong or any other way to do my task easily. Thanks.

Tangle
  • 51
  • 1
  • 11
  • If not how to see the TableLayout as ListView has much more data and this is a requirement ,need to some of data in ListView and other set in Table in same screen. Both have big data set – Tangle Jul 09 '15 at 05:09

3 Answers3

1

As far as I know, you should never put a ListViewinside a ScrollView, since they implement their own scrolling behavior. Consider changing your design.

Kise
  • 2,823
  • 1
  • 24
  • 43
0

I think you can fix it by using the

layout_weight 

set layout_weight for your ListView to 1 and for TableLayour set it to 0;

Be sure after changing set layot*:height to 0dp;

You can check below articles.

first- second-

Community
  • 1
  • 1
RajSharma
  • 1,941
  • 3
  • 21
  • 34
0

"I knew that android scrollview can only have one child." Correct but you forget that that one child should have a height of wrap_content.
Also @haint is correct ListView has its own Scrolling Behavior. Still try android:layout_height="wrap_content" for your LinearLayout

Azim Ansari
  • 1,378
  • 11
  • 20