Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In this code i have two table layouts one for table headers and another one for table data.I had designed headers with in the .xml file itself and another table layout pro-grammatically.

Now my task is to,when i scroll horizontally table data(second table layout) the table header(first table) layout also have to scroll horizontally.

By using this below code when i scroll second table layout the first one was not scrolling.





<relativelayout xmlns:android="http://schemas.android.com/apk/res/android">
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:removed="#3b5998" >

<relativelayout>
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ImageView
android:id="@+id/test_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:src="@drawable/logo" />

<Button
android:id="@+id/btnview"
android:layout_width="40dp"
android:layout_height="30dp"
android:layout_alignBaseline="@+id/etxt_todate"
android:layout_alignBottom="@+id/etxt_todate"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="@drawable/custombutton"
android:text="GO"
android:textColor="#ff0000" />

<edittext>
android:id="@+id/etxt_todate"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_below="@+id/test_image"
android:layout_marginLeft="20dp"
android:layout_marginTop="23dp"
android:layout_toRightOf="@+id/etxt_fromdate"
android:removed="@drawable/customedit"
android:ems="10"
android:hint="ToDate" />

<edittext>
android:id="@+id/etxt_fromdate"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/etxt_todate"
android:layout_alignBottom="@+id/etxt_todate"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:removed="@drawable/customedit"
android:ems="10"
android:hint="FromDate" />

<textview>
android:id="@+id/txtheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:fontFamily="Bold"
android:text="COLLECTION SUMMARY"
android:textColor="#ffff00"
android:textSize="15sp" />


<tablelayout>
android:id="@+id/tbmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="140dp"
>

<tablerow>
android:id="@+id/tbheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<textview>
android:id="@+id/tbhcol1"
android:layout_width="150dp"
android:layout_weight="1"
android:removed="#dcdcdc"
android:gravity="center"
android:text="BRANCH"
android:textColor="#ff0000" />

<textview>
android:id="@+id/tbhcol2"
android:layout_width="120dp"
android:layout_weight="1"
android:removed="#cac9c9"
android:gravity="center"
android:text="CASH"
android:textColor="#ff0000" />

<textview>
android:id="@+id/tbhcol3"
android:layout_width="120dp"
android:layout_weight="1"
android:removed="#dcdcdc"
android:gravity="center"
android:text="CARD"
android:textColor="#ff0000" />

<textview>
android:id="@+id/tbhcol4"
android:layout_width="120dp"
android:layout_weight="1"
android:removed="#cac9c9"
android:gravity="center"
android:text="REFUND"
android:textColor="#ff0000" />
<textview>
android:id="@+id/tbhcol5"
android:layout_width="120dp"
android:layout_weight="1"
android:removed="#cac9c9"
android:gravity="center"
android:text="TOTAL"
android:textColor="#ff0000" />



<scrollview>
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="155dp" >

<horizontalscrollview>
android:id="@+id/horizontalScrollView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<tablelayout>
android:id="@+id/tblayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >




Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900