android利⽤xml实现分割线因为没有美⼯, 所以只能⾃⼰动⼿了。
在layout⽂件夹⾥的xml 写
⽅法1:在layout⾥⾯的布局xml ⽂件⾥加上⾯的代码
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/orange_normal" />
效果图
在drawable⽂件夹⾥⽤ shape line 或 rectangle 先画线
⽅法2:在drawable⾥⾯⽤shape新建⼀个xml
然后在 layout ⾥的布局⽂件⾥引⽤
这种⽅法可以多处引⽤同⼀个 line 样式
<!-- drawable/l -->
<shape xmlns:android="schemas.android/apk/res/android"
android:shape="line" >
<stroke android:color="@color/orange_normal" />
</shape>
或者⽤填充的矩形实现
<shape xmlns:android="schemas.android/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/orange_normal" />
<size
android:height="1dp"
android:width="100dp" />
</shape>android layout布局
Note
android:width=”100dp” 不能赋值为 “match_parent”
在layout/l ⾥⾯引⽤
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/line_my" />
希望本⽂所述对⼤家学习Android软件编程有所帮助。