I'm trying to write a text on canvas but nothing happens

I'm tryin to write a text on canvas and set as GL10 object texture like this:

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
    bitmap.eraseColor(0);

    Canvas canvas = new Canvas(bitmap);
    canvas.translate(width, height);
    canvas.drawColor(Color.WHITE);

    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(0xffffffff & Color.MAGENTA);
    paint.setAlpha(255);
    canvas.drawText("Hello world", 0, 30, paint);

the texture color is drawn if i change but the text not apears. some one know why ?

Upvotes: 0

Views: 52

Answers (1)

Marco Avila
Marco Avila

Reputation: 81

It looks like the alpha setting is missing on the paint object that draws the text:

paint.setAlpha(255); //This line must be after paint.setColor(Color.MAGENTA);

or

paint.setColor(0xffffffff & Color.MAGENTA);

Upvotes: 1

Related Questions