I tried looking at numerious examples and posts but none of them matches my problem.
I need to make a very long (horizontal) table with many columns so it is impossible to display in a single screen. And I don't want to spilt the table because it is important that I display my table in this way.
I have pasted my XML layout below (including the main important ones)
The thing is if I remove the code:
android:fillViewport="true"
from the HorizontalScrollView then my table inside it, gets squeezed in one place, especially at the left side of it. It doesn't even use much of this HorizontalScrollView container area.
And, If I use this code, then this HorizontalScrollView shows my whole table inside it - the columns are squeeze to make sure they fit in this scrollview.
I just want this scrollview to display only the content of my tablelayout that fits in the screen width, so I can scroll the remaining columns. But right now, I don't seem to get anywhere near.
So how do I solve my problem? Am I doing something wrong ?
Also here is my XML layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:fillViewport="true">
<TableLayout
android:id="@+id/bot_scoreBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/table_shape"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow
android:layout_height="fill_parent"
android:layout_margin="2dp"
android:background="#ffffff"
>
<TextView
/>
....
more than 16 columns of made using TextView
....
</TableRow>
</TableLayout>
</HorizontalScrollView>
</LinearLayout>
I got the answer. It was because I was using the
in the TableLayout.
Plus my TextView which were the columns, needed to some specific width size rather than just
Those were the problems.
You are using
android:stretchColumns="*"
you have to use some definite value with yourlayout_width
instead ofmatch_parent
andwrap_content
.for ex.
layout_width = "250dp"
You should wrap your
TableLayout
with aLinearLayout
.