I know there have been several posts about this, but I can't get this working. I want a table with a header that stays visible while scrolling through the contents of the table. I'm fond of this approach: http://www.entreotrascosas.net/creating-dynamic-scrollable-fixed-header-tables-in-android/
Here's my xml. I got two TableLayouts, one for the header and one for the contents. I filled them with one row each, with layout_height
set to 0dp
.
<TableLayout
android:id="@+id/headerLayout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/hiddenLongestRow"
android:layout_width="wrap_content"
android:layout_height="0dp" />
</TableLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/headerLayout"
android:fadeScrollbars="false" >
<TableLayout
android:id="@+id/contentLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:id="@+id/hiddenHeaderRow"
android:layout_width="wrap_content"
android:layout_height="0dp" />
</TableLayout>
</ScrollView>
I then programmatically fill the tables with my values and the rows specified in my xml with dummy values for the header / the longest row. Now, the columns of both tables have the same width. So far, so good.
But now I need the two dummy rows to disappear. It was said setting the height to 0dp
would do this, but for me it doesn't, the rows are always visible.
I tried setting the height of the LayoutParams to 0 programmatically, but it didn't help. Setting the visibility to INVISIBLE or GONE does not do the job. What else can I do?
You can try to remove it: