Search code examples
androidandroid-layoutandroid-tablelayoutandroid-scrollview

Scrollable tableLayout


How can I implement scrollable tableLayout in the following image, the problem is how to insert views in the table like this order.

Did it needs adapter to insert views in the tableLayout? if yes, how it is work ?

image of the scrollable TableLayout http://dl.dropbox.com/u/42106750/scrollview.jpg and here is a snippet of xml UI

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/body_tile_bg"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        style="@style/InitSelectAppsParagraphHeader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="8dp"
        android:text="@string/init_Select_apps_use_the_force" />

    <TextView
        android:id="@+id/textView2"
        style="@style/InitSelectAppsParagraphBody"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="8dp"
        android:gravity="center_horizontal"
        android:text="@string/init_Select_apps_paragraph" />

</LinearLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2" 
    android:padding="8dp" >

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

   </TableLayout>
</ScrollView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="12dp"
        android:background="@color/init_select_apps_grey_bg"
        android:paddingBottom="4dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="4dp" >

        <TextView
            android:id="@+id/textView3"
            style="@style/InitDarkBackgroundTextStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/choose" />

        <TextView
            android:id="@+id/textView4"
            style="@style/InitSelectAppsGreenBigText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:text="4"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView5"
            style="@style/InitDarkBackgroundTextStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/init_select_apps_more_to_continue" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="38dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="16dp"
        android:background="@color/init_select_apps_grey_bg"
        android:paddingLeft="8dp"
        android:paddingRight="8dp" >

        <TextView
            android:id="@+id/textView6"
            style="@style/InitDarkBackgroundTextStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="@string/init_select_apps_add_much" />

        <Button
            android:id="@+id/button1"
            style="@style/InitNextButton"
            android:layout_width="wrap_content"
            android:layout_height="28dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="16dp"
            android:text="@string/next" />

    </LinearLayout>

</LinearLayout>


Solution

  • Its not a scrollable tableView or anything. Its a simple GridView. You can create an adapter to populate your GridView as given in this tutorial.