0

I have a linear layout containing a tablelayout and a relative layout

The relative layout is set as a footer Inside the table layout I position several other components (textviews, editboxes, buttons)

and I would like this table layout to have a scrollbar

I set its property to have a vertical scrollbar already but it doesn't work

Here is my layout

<LinearLayout xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:scrollbarStyle="insideOverlay"
    android:scrollbars="vertical"
    tools:context="com.teo.cuteoeditor.PreferenceActivity$PlaceholderFragment" xmlns:android="http://schemas.android.com/apk/res/android">

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarStyle="insideOverlay"
        android:scrollbars="vertical" >

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp" >

            <include
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                layout="@layout/pref_title_layout"
                android:scrollbarStyle="insideOverlay"
                android:scrollbars="vertical" />

            </TableRow>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#42424242" />

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp" >

            <include
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                layout="@layout/pref_desc_layout"
                android:scrollbars="vertical" />

            </TableRow>
        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#42424242" />

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp" >

            <include
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                layout="@layout/pref_location_layout"
                android:scrollbarStyle="insideOverlay" />

            </TableRow>
        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#42424242" />

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp" >

            <include 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                layout="@layout/pref_time_to_from" />
        </TableRow>
        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#42424242" />

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp" >

            <include 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                layout="@layout/pref_reminder" />
        </TableRow>
    </TableLayout>
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#42424242" />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom|center_vertical|center_horizontal" >

        <Button
            android:id="@+id/pref_save_btn"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="100dp"
            android:layout_height="35dp"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_centerInParent="false"
            android:text="@string/pref_cancel" />

        <Button
            android:id="@+id/pref_cancel_btn"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="100dp"
            android:layout_height="35dp"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="false"
            android:layout_centerInParent="false"
            android:layout_centerVertical="false"
            android:layout_marginRight="10dp"
            android:text="@string/pref_save" />

    </RelativeLayout>

</LinearLayout>

Look at the 3 editbox, if this activity resource is called, and my cursor focuses on the third editbox, android automatic keyboard shows up and it covers my 3rd editbox . the screen should pull up itself to let me know where my cursor is such that I can input in the box, right ?

user3431664
  • 51
  • 1
  • 10

1 Answers1

0

Encase the whole thing in:

<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="none"
        android:layout_weight="1">
        <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">


       </LinearLayout>
     </ScrollView>

Also Check out:: How to scroll table layout in horizontal and vertical in android

Community
  • 1
  • 1
ASP
  • 3,645
  • 1
  • 31
  • 45