lundi 29 juin 2015

How to place check boxes in center in table layout

I am having a table layout having 12 rows and 5 columns for each row at the last column check box was there now I want to place my check box at the center of the check-box column can any one tell me how to place check box in center of table row in android

This is my drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg" 
    android:shape="rectangle"
    >
    <solid android:color="#FFFFFF"/>
    <stroke android:width="1dp" android:color="#9e9e9e"/>


</shape>

This is my table layout

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.developer.milanandroid.Manual_AC_Fuse_ckt" >




    <TableLayout
        android:id="@+id/table_layout_manual_mode"
        android:layout_width="match_parent"

        android:shrinkColumns="3"
        android:stretchColumns="4" >

        <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>

        <TableRow
            android:id="@+id/tableRow4_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_18_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_18_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_18"
                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_18_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_4"
                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/tableRow5_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_19_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_19_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_19"
                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_19_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_5"
                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/after_fuse_second_heading"
            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 P11"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow6_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_20_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_20_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_20"
                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_20_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_6"
                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/tableRow7_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_21_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_21_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_21"
                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_21_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

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



    </TableLayout>

         </ScrollView>


</RelativeLayout>




Aucun commentaire:

Enregistrer un commentaire