在drawBitmap中重复Bitmap

时间:2014-03-18 16:54:49

标签: android bitmap

我尝试重复Bitmap,但不重复,

    private Bitmap dot;
    Paint p;
public view(Context context) {
    super(context);
    dot= BitmapFactory.decodeResource(getResources(), R.drawable.dot);
    p = new Paint();
    p.setShader(new BitmapShader(dot, TileMode.REPEAT, TileMode.REPEAT));
}

protected void onDraw(Canvas canvas) {
    canvas.drawColor(Color.BLACK);
    canvas.drawBitmap(dot, 0, 0, p);
}

任何其他想法?
除非使用BitmapDrawable。?

1 个答案:

答案 0 :(得分:1)

而不是

canvas.drawBitmap

呼叫

canvas.drawRect(0, 0,  getWidth(), getHeight(), p)