1

How can I setup ScrollView vertically & horizontally? I tried with the code below, but it didn't work.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarFadeDuration="1000"
        android:scrollbarSize="12dip"
        android:background="@color/red" >

        <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TableLayout android:layout_width="match_parent"  android:layout_marginTop="10dp" android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:stretchColumns="1" android:collapseColumns="2">

            </TableLayout>
        </HorizontalScrollView>
</ScrollView>

Here is my all code: http://pastebin.com/ysRhLMyt

Mischa
  • 42,876
  • 8
  • 99
  • 111
Piraba
  • 6,974
  • 17
  • 85
  • 135

4 Answers4

1

Try,

Set the android:scrollbarFadeDuration="0"

       OR 

ScrollView1.setScrollbarFadingEnabled(false);

       OR

android:scrollbarFadeDuration="0" and

android:scrollbarAlwaysDrawVerticalTrack="true" for vertical

android:scrollbarAlwaysDrawHorizontalTrack="true" for horizontal

And one more thing,

Remember, the ScrollView can have only one child control, so we can make a container (Linear, relative, Table Layouts) the child of the ScrollView and put all the controls inside this child.

For reference: http://android-pro.blogspot.com/2010/02/android-scrollview.html

TableLayout ScrollView Vertical & Horizontal

Community
  • 1
  • 1
Piraba
  • 6,974
  • 17
  • 85
  • 135
1

Try changing the height of the ScrollView to "fill_parent".

Arnab Chakraborty
  • 7,442
  • 9
  • 46
  • 69
1

If it is the rows you want to move horizontally, then i suggest designing your layout like

Scrollview as parent , table layout as its only child, and then add the table rows to the table layout , put the horizontalscrollview inside each table row. This way you can move the table vertically and the rows in the table horizontally.

hope this helps.

Yashwanth Kumar
  • 28,931
  • 15
  • 65
  • 69
0

The Linear layout (@+id/linearLayout3) orientation is horizontal, make it vertical so that the content is shown below. I think presently, your list divider and list items are added horizontally on the screen, instead vertically.

rDroid
  • 4,875
  • 3
  • 25
  • 30