我们需要一个drawable,它在左边有大约10dp的背景和渐变色。实现效果如下图所示:
![enter image description here](https://istack.dev59.com/251Kc.webp)
实现方法如下:
这是需要实现的Item的背景:
![enter image description here](https://istack.dev59.com/251Kc.webp)
实现方法如下:
- 在左侧添加红色渐变
- 其余部分添加背景色
这是需要实现的Item的背景:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/background" />
<item android:drawable="@drawable/gradient" />
</layer-list>
背景可绘制对象:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/black" />
</shape>
形状可绘制:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"
android:angle="90"/>
<size android:width="10dp" />
</shape>