在BY中,使用XML定义矩形的单边或多边线条方法比较简单,只需通过“borderMode”指定即可。
参考下面例子(定义顶部描边):
<shape>
<stroke width="1dp" color="#f00" borderMode="top" />
</shape>
对比Android中,以下方法定义一个单边线条的图形会复杂些:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<stroke android:width="1dp"
android:color="@color/black"/>
</shape>
</item>
</layer-list>