android:如何显示TableLayout的边框

android:如何显示TableLayout的边框,android,tablelayout,Android,Tablelayout,如何突出显示表格布局的边框。。。 我正在使用以形状为背景的roundshape.xml,我一定有办法在你的表格布局周围画出边框 roundshape.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners andro

如何突出显示表格布局的边框。。。 我正在使用以形状为背景的roundshape.xml,我一定有办法在你的表格布局周围画出边框

roundshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <corners android:radius="5dip" />

    <gradient
        android:angle="270"
        android:endColor="@color/WhiteSmoke"
        android:startColor="@color/WhiteSmoke"
        android:type="linear" />

</shape>

白烟=#f5

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="400dp"
        android:layout_height="400dp"
        android:background="@drawable/roundshape"
         >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </TableRow>
    </TableLayout>

</LinearLayout>

关于这一点,这里已经有一篇非常类似的帖子

大卫·杰西

我解决这个问题的方法是在 每个单元格的背景字段。通过这种方式,您可以定义 使用所有单元格所需的边框进行造型。唯一的不便 极端单元格的边框宽度为 其他,但如果您的表格填满整个屏幕,则没有问题


我想这可能会对你有所帮助。。仔细检查代码,你会发现诀窍的

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="400dp"
        android:layout_height="400dp"
        android:background="@drawable/roundshape" >

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#ff9" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is amazing" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#ff9" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is amazing" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#ff9" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is amazing" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#ff9" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is amazing" />
        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#ff9" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="1px"
                android:text="" />
        </TableRow>
    </TableLayout>

</LinearLayout>