我知道它有可能使一个形状看起来像这样:
I know it is possible to make a shape looking something like this:
但我不知道如何开始使用它。我可以把它作为一个形状?或做我必须做点别的?
But I don't know how to start with it. Can I make it as a shape? or do I have to do something else?
BR
哦,看看那个,我错了 - 梯度都不是问题:
Oh look at that, I was wrong - gradients are not a problem:
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.view.View;
public class ButtonShadow extends View {
public ButtonShadow(Context context)
{
super(context);
}
@Override
public void onDraw(Canvas canvas)
{
RectF space = new RectF(this.getLeft(), this.getTop(), this.getRight(), this.getBottom());
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setShader(new LinearGradient(0, getWidth(), 0, 0, Color.BLACK, Color.WHITE, Shader.TileMode.MIRROR));
canvas.drawArc(space, 180, 360, true, paint);
Rect rect = new Rect(this.getLeft(),this.getTop() + (this.getHeight() / 2),this.getRight(),this.getBottom());
canvas.drawRect(rect, paint);
}
}
更多关于渐变填充看这里:How填写Android的一个路径的线性梯度?