如何在表格布局列的中心设置视图

时间:2015-06-29 09:57:14

标签: android checkbox tablelayout

我有一个带有五列表格布局的复选框,我在表格布局的最后一列放置了复选框,但它没有放在列的中心,任何人都可以告诉我如何放置支票android中的表格布局中列的中心框

这是我的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 个答案:

没有答案