在android中画一个表格

在这样 滑稽
在这里插入图片描述
先定义2个画图的item.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
//把右和上取消显示
        <item android:right="-2dp" android:top="-2dp">
            <shape>
            //设置了宽度和颜色
                <stroke android:width="3dp" android:color="@color/gray1"/>
            </shape>
        </item>
</layer-list>

第2个xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
//把左边和下取消显示
        <item android:left="-2dp" android:bottom="-2dp">
            <shape>
                <stroke android:width="3dp" android:color="@color/gray1"/>
            </shape>
        </item>
</layer-list>

在布局上填充
先进行最大的填充把左边和下边进行填充 只需要一次
在进行单个填充 每个都需要 (上和右)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
            android:orientation="vertical"
             tools:context="com.gsandroid.trafficclient.fragment.TrafficLightMainFragment">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="红绿灯管理"
            android:textSize="40dp"
            android:textColor="@color/black"/>
    </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:padding="15dp">
                <TextView
                    android:layout_width="120dp"

                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:text="排序"
                    android:textSize="25dp"
                    android:textColor="@color/black"
                    android:textStyle="bold"/>
                <Spinner
                    android:id="@+id/sp_sort"
                    android:layout_width="220dp"

                    android:layout_height="wrap_content">
                </Spinner>
                <Button
                    android:id="@+id/btn_query"
                    android:layout_width="60dp"

                    android:layout_height="wrap_content"
                    android:text="查询"
                    android:textSize="20dp"
                    android:background="@drawable/item_buttom"
                   />
            </LinearLayout>
            //先画的左和下
            **<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_margin="20pt"
                android:background="@drawable/item_trafficlight"
                >**
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:gravity="center_vertical">
                    <TextView
                        **android:background="@drawable/item_trafficlight_left"**   
                        android:text="路口"
                        android:textSize="10pt"
                        android:layout_weight="2"
                        android:gravity="center"
                        android:layout_width="0dp"
                        android:layout_height="80dp" />
                    <TextView
                        android:background="@drawable/item_trafficlight_left"
                        android:text="红灯时长(s)"
                        android:textSize="10pt"
                        android:layout_weight="3"
                        android:gravity="center"
                        android:layout_width="0dp"
                        android:layout_height="80dp" />

                    <TextView
                        android:layout_width="0dp"

                        android:layout_height="80dp"
                        android:layout_weight="3"
                        android:background="@drawable/item_trafficlight_left"
                        android:gravity="center"
                        android:text="黄灯时长(s)"
                        android:textSize="10pt" />
                    <TextView
                        android:background="@drawable/item_trafficlight_left"
                        android:textSize="10pt"
                        android:text="绿灯时长(s)"
                        android:gravity="center"
                        android:layout_weight="3"
                        android:layout_width="0dp"
                        android:layout_height="80dp" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <ListView
                        android:id="@+id/lv_lightTime"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
                </LinearLayout>
            </LinearLayout>
   


</LinearLayout>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值