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.
As far as I know, you should never put a ListView
inside a ScrollView
, since they implement their own scrolling behavior. Consider changing your design.
"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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.