Question

Below given is my layout which is I am using for displaying a table, which have a number of rows. the problem is this table have more no of rows than the screen can contain, so i want rows to be scrollable so that if i scroll down i can reach to the rows which is not visible in current screen. i used isScrollContainer="true" bur this does not solve my problem Can you please suggest which property can i use to solve the problem

            <TableLayout android:layout_height="wrap_content" android:isScrollContainer="true" >
                <RelativeLayout android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:gravity="center">
                    <View android:layout_gravity="center" android:layout_height="30px"
                        android:background="@android:color/darker_gray"
                        android:layout_width="400px" />
                    <TextView android:layout_width="wrap_content" style="@style/styleName"
                        android:id="@+id/tv_add_ticket" android:text="Update Ticket on Assembloid Space"
                        android:layout_height="wrap_content" android:layout_marginLeft="5px"
                        android:layout_marginRight="2px" android:layout_marginTop="2px"
                        android:layout_marginBottom="2px">
                    </TextView>
                </RelativeLayout>
            </TableLayout>  

        <TableLayout android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:layout_margin="20px" android:isScrollContainer="true"
            xmlns:android="http://schemas.android.com/apk/res/android" 
            android:baselineAligned="true" android:background="#565051"
            android:layout_marginTop="50px">
            <TableRow>
                <TextView android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:id="@+id/ticket_status"
                    android:text="Status " android:layout_column="1" />

                <TextView android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:text=":"
                    android:layout_column="2" android:layout_marginTop="5px"
                    android:layout_marginRight="5px" />

                <!-- <EditText android:layout_width="250px" android:layout_height="wrap_content" 
                    android:id="@+id/et_ticket_status"></EditText> -->
                <Spinner android:layout_width="100px" android:layout_height="wrap_content"
                    android:id="@+id/spn_up_ticket_status"></Spinner>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/ticket_priority"
                android:text="Priority" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />

            <Spinner android:layout_width="200px" android:layout_height="wrap_content"
                android:id="@+id/spn_up_ticket_priority"></Spinner>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/ticket_summary"
                android:text="Summary" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />
            />
            <EditText android:layout_width="250px" android:id="@+id/et_ticket_summary"
                android:layout_height="wrap_content" android:autoText="true">

            </EditText>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/ticket_discription"
                android:text="Discription" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />
            />
            <EditText android:layout_width="250px" android:id="@+id/et_ticket_Discription"
                android:layout_height="wrap_content" android:autoText="true"></EditText>
        </TableRow>
        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/estimated_hour"
                android:text="Estimated Hours" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />
            />
            <EditText android:layout_width="250px" android:id="@+id/et_estimated_hour"
                android:layout_height="wrap_content" android:autoText="true"></EditText>
        </TableRow>

        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/worked_hour"
                android:text="Worked Hours" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />

            <EditText android:layout_width="250px" android:id="@+id/et_worked_hour"
                android:layout_height="wrap_content" android:autoText="true"></EditText>
        </TableRow>

        <TableRow>
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/ticket_comment"
                android:text="Comment" android:layout_column="1" />
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text=":"
                android:layout_column="2" android:layout_marginTop="5px"
                android:layout_marginRight="5px" />
            />
            <EditText android:layout_width="250px" android:id="@+id/et_ticket_comment"
                android:layout_height="wrap_content" android:autoText="true">

            </EditText>
        </TableRow>

        <TableRow>
            <Button android:layout_width="wrap_content" android:text="Comments"
                        android:layout_height="wrap_content" android:id="@+id/comment_ticket_button"    android:layout_column="1" ></Button>

            <Button android:layout_width="wrap_content" android:text="@string/update_ticket"
                        android:layout_height="wrap_content" android:id="@+id/update_ticket_button" android:layout_column="3"></Button>

        </TableRow>

        <TextView android:id="@+id/error_ticket_text"
            android:layout_centerHorizontal="true" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_below="@+id/login_button" />

Was it helpful?

Solution

You should wrap your TableLayout inside a ScrollView with appropriate height

 <ScrollView android:id="@+id/ScrollView01"
  android:layout_width="fill_parent"
  android:layout_height="100dp">
    <TableLayout..>
    </TableLayout>
 </ScrollView>

OTHER TIPS

You should use ScrollView as the root layout to solve your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top