Android LinearLayout显示分割线有两种方式:
1.使用一个宽/高为1dp的View:
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF0000" />
2.直接使用LinearLayout的divider属性:
先做一个 Drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:height="1dp"/>
<solid android:color="#FF0000"/>
</shape>
然后像这样使用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@drawable/divider"
android:orientation="vertical"
android:showDividers="middle" >
后一种方法更推荐一些。