How to setview in center of a table layout column

45 views Asked by At

I am having a check box with in table layout of five columns and i had placed check boxes in the last column of my table layout but it was not placing at the center of the column can any one tell me how to place check boxes at the center of the column in the table layout in android

This is my xml

<TableLayout
        android:id="@+id/table_layout_manual_mode"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
         >

        <TableRow
            android:id="@+id/After_connection_heading_one"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#673AB7" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="CHECK ON J14"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow1_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_15"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"

                />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_16"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_17"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>
</TableLayout>

This is what i had been facing but i need them in center

0

There are 0 answers