0

I have use two Scroll view in One activity.Each scroll view inner add table layout.Each table layout add records in programmatically from my database value.I need add 10 records in each table at a time scroll view height in wrap content and more than 50 records add to table scroll view maximum height set in 500.How I do this?Please help me. Follow my XML code

main_activity.xml

<ScrollView
    android:id="@+id/scrollView2"
    android:layout_width="fill_parent"
    android:layout_height="450dp"
    android:layout_alignParentRight="true">
    <TableLayout
          android:id="@+id/main_table" 
          android:layout_width="fill_parent"    
          android:layout_height="wrap_content" 
          android:stretchColumns="0,1" 
          android:layout_column="0"
          android:layout_weight="1.0" 
          android:layout_below="@+id/relativeLayout" 
          android:layout_alignParentLeft="true"
        xmlns:android="http://schemas.android.com/apk/res/android" />
</ScrollView>

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/req_head"
    android:layout_below="@+id/scrollView2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="10dp"></TableLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:id="@+id/scrollView4"
    android:layout_below="@+id/req_head"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="0dp">

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/maintable2">
    </TableLayout>

</ScrollView>
3
  • 1
    first of all you cannot add two scrollviews in one layout. this layout is wrong...
    – Umair
    Sep 16, 2015 at 5:33
  • Tnx for replay. Already I have use two scroll view in One relative layout.its's Work.I need how to set maxmium height for scrollview more then 50 records in table Sep 16, 2015 at 5:40
  • you are taking it wrong. the records will show according to screen size of the device not according to scrollview. if you want to set height to full screen then use android:fillViewport="true"
    – Umair
    Sep 16, 2015 at 5:44

1 Answer 1

0

if i follow your question, I think you need to fix the scroll views height. And scroll view can be more than one..In that case put your ScrollView into a LinearLayout make the height of scroll view wrap_content and fix the size of parent LinearLayuot according to your need. like:

<?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:orientation="vertical" >

  <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="450dp"
    android:orientation="vertical" >

      <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TableLayout
              android:id="@+id/main_table" 
              android:layout_width="fill_parent"    
              android:layout_height="wrap_content" 
              android:stretchColumns="0,1" 
              android:layout_column="0"
              android:layout_weight="1.0" 
              android:layout_alignParentLeft="true" />
       </ScrollView>
</LinearLayout>


<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/req_head"
    android:layout_marginTop="10dp"></TableLayout>

  <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView4">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/maintable2">
        </TableLayout>

    </ScrollView>
</LinearLayout>    

</LinearLayout>
2
  • Tnx for Answer @sourabh bans.i try this code but table layout (req_head) android:layout_below="@+id/scrollView2" occurred error.I need to first scrollview2 below set second one table layout and second scrollview4. Sep 18, 2015 at 6:04
  • it is the property of relative layout , that applied on child views to create relation with each other.. you can define that element in each LinearLayout.
    – SRB Bans
    Sep 18, 2015 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.