【发布时间】:2011-03-14 15:26:20
【问题描述】:
我遇到了 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>
【问题讨论】: