我试图在android中绘制渐变
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int x = 0;
int y = 20;
int gh = this.height /4 ;
int gw = this.width;
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setTextSize(10);
for(Todo t : todos){
canvas.drawText(t.title, x, y, paint);
grad.setBounds(x, y, gw, gh);
grad.draw(canvas);
y+= gh;
}
this.invalidate();
}
和渐变
GradientDrawable grad = new GradientDrawable(Orientation.TOP_BOTTOM,
new int[]{0xffffffff, 0xffff00ff});
todo标题绘制,但没有渐变。当我刚刚在0,0绘制渐变时,它工作正常
答案 0 :(得分:0)