Reputation: 1466
I currently have a table in an android application that I am developing for a class to which content is added dynamically from the code. The set of data that is added to the table will be rather large, so the table must be able to scroll. I needed to have a fixed header that remains as the rest of the content scrolls. In order to do this, I put the header in a completely separate TableLayout
, with an additional invisible row to keep the formatting neat, as per the method described on this blog.
However, I find that, despite making the row invisible, a vertical space where the row would go is present. In the example given in the blog, the height of each TextView
within the dummy (invisible) row is set to "0dp"
. However, trying to set the height of the table by getting the LayoutParams
and setting the height
property to 0
seems to create more problems. It makes a larger space, meanwhile making the actual header content completely invisible.
Unfortunately, I am restricted from using outside libraries by my teacher, so I really need a solution to this problem instead of an alternative such as TableFixHeaders.
Upvotes: 0
Views: 560
Reputation: 370
To expand on my comment above, I would have something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linerarLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="@string/myText"/>
</LinearLayout>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linerarLayout1" >
</ListView>
</RelativeLayout>
I changed the parent to RelativeLayout
Upvotes: 1