Piraba
Piraba

Reputation: 7014

Use ScrollView & HorizontalScrollView in TableLayout

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

Upvotes: 1

Views: 3635

Answers (4)

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

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.

Upvotes: 1

Arnab Chakraborty
Arnab Chakraborty

Reputation: 7472

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

Upvotes: 1

Piraba
Piraba

Reputation: 7014

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

Upvotes: 1

rDroid
rDroid

Reputation: 4945

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.

Upvotes: 0

Related Questions