我在XML中使用LinearGradient定义时遇到了小问题。我想要使用接受颜色数组和位置数组的构造函数。
就是这个构造函数:
LinearGradient(float x0, float y0, float x1, float y1,
int[] colors, float[] positions, Shader.TileMode tile)
我该如何将数组传递到XML中?这是一个带有渐变定义的XML示例,但它很简单。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#474946"
android:endColor="#181818"
android:angle="270"/>
<corners android:radius="5dp" />
</shape>