0

My problem is that after I create TableLayout in code, I'm adding it to the activity view and I really need it to be scrollable. The table is created from resultset containing result of SQL query and it may differ depending on the query itself, so it has to be 'universal', not always scrollable. I've found answers to scrolling problems like that here at stackoverflow and after some reading, I've built my activity like that:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:clickable="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="insideOverlay"
android:scrollbars="horizontal|vertical"
android:visibility="visible"
tools:context=".Wyswietlanie" >

<RelativeLayout
android:id="@+id/rel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
 >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="23dp"
    android:text="@string/wczytywanie"
    android:textAppearance="?android:attr/textAppearanceLarge" />





</RelativeLayout>
</ScrollView>

In code, I'm simply adding my generated TableLayout like this:

rl1.addView(result);

Where rl1 is the relative layout (found by id), and result is the TableLayout. TableLayout shows itself, but nothing is scrollable. No scrollbars are visible, nothing happens when I'm sliding my finger over it in different directions. Nothing at all. Where is my mistake? Should I use something else?

(please ignore the fact that obviously the generated tablelayout is overlapping the textview, I saved it for later.)

kdkade
  • 65
  • 7

1 Answers1

0

Try changing the layout width of the scrollview to match_parent.

android:layout_width="match_parent"
android:layout_height="match_parent"
Yojimbo
  • 23,288
  • 5
  • 44
  • 48
  • It's still not working, at least not horizontally. Finally, I used this [click here](http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android) – kdkade Aug 15 '13 at 15:12