在日常android的开发过程中,我们会遇到这样的一个需求。我只想给控件加左边框或者右边框,当然方法有很多种了。下面就不列举了,我就分享一个我认为比较好的实现方式吧。
首先要了解shape中gradient的原理,这里就不多说了,不明白的就自己去google。
分别定义左边框、底边框、右边框、上边框。
left-border
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- left border -->