ドローアブルのメソッドを使用しShapeDrawable
てカスタムを含むを埋めるのに問題があります。次のコードは、 を描画するときに完全に機能します。PathShape
setShaderFactory()
RectShape
ShapeDrawable shape = new ShapeDrawable();
shape.setShape(new RectShape());
shape.setShaderFactory(new ShaderFactory() {
@Override
public Shader resize(int width, int height) {
LinearGradient gradient = new LinearGradient (0, 0,
width, height, Color.Red, Color.Blue,
TileMode.REPEAT);
return gradient;
}
});
RectShape
ただし、を任意の customに変更するとPathShape
、drawable は形状全体をグラデーションの開始色 (赤) のみで塗りつぶします。つまり、カスタム シェイプは正しく描画されますが、色は完全に間違っています。誰もこれを前に見て、何が問題なのか知っていますか?