在这样 滑稽
先定义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>