nasaa
nasaa

Reputation: 2731

Cant get scroll bar in android

I cant seem to get scroll bar with ths following layout.

<TableLayout android:layout_height="wrap_content"
    android:stretchColumns="*" android:background="#ff0000"
    android:layout_margin="1dip" android:layout_width="75dip"
    android:layout_gravity="center">
    <TableRow android:background="@color/custom_button_bggreen"
        android:layout_margin="2dip">
        <TextView android:text="H" android:background="@color/custom_button_bggreen"
            android:gravity="center" android:textSize="20dip" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000" android:layout_margin="1dip">
    <TableRow android:background="@color/custom_button_bggreen"
        android:layout_margin="2dip">
        <TextView android:text="Hydrogen" android:background="@color/custom_button_bggreen"
            android:gravity="center" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000" android:layout_margin="1dip">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:text="General Properties"
            android:background="#0000ff" android:gravity="center" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
</TableLayout>


<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000" android:layout_margin="1dip">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:text="Physical Properties"
            android:background="#0000ff" android:gravity="center" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000" android:layout_margin="1dip">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:text="Atomic Properties"
            android:background="#0000ff" android:gravity="center" />
    </TableRow>
</TableLayout>

<TableLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:stretchColumns="*"
    android:background="#ff0000">
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
    <TableRow android:background="#00ff00" android:layout_margin="2dip">
        <TextView android:id="@+id/button" android:text="+"
            android:background="#0000ff" android:layout_margin="2dip"
            android:gravity="left" />
        <TextView android:text="label" android:background="#0000ff"
            android:layout_margin="2dip" android:gravity="left" />
    </TableRow>
</TableLayout>


<Button android:layout_width="80dip" android:layout_height="wrap_content"
    android:text="Back" android:id="@+id/backkButton"
    android:layout_gravity="center"></Button>

Can any one of you point the problem please?

Thanks.

Upvotes: 0

Views: 937

Answers (2)

plugmind
plugmind

Reputation: 7986

It looks you only posted part of your layout. I will try to help anyway:

<ScrollView ....>

    <LinearLayout android:orientation="vertical" ...>

     YOUR SCROLLABLE CONTENT HERE

    <LinearLayout>

</ScrollView>

Upvotes: 3

Nick H
Nick H

Reputation: 11535

Views don't scroll by default, except for a few exceptions like TextView. You have to use ScrollView - place your stuff in a LinearLayout and then place that inside the ScrollView.

Upvotes: 0

Related Questions