1. Are you ready for the Galaxy S20? Here is everything we know so far!

Re-using Paint objects?

Discussion in 'Android Development' started by safibaba, May 22, 2010.

  1. safibaba

    safibaba Newbie
    Thread Starter

    Will it really slow things down if I use one text paint to draw 3 different lines of text in a repeating draw routine in different colors like this...

    PHP:
    1. textPaint.setARGB(255,255,255,255);
    2. c.drawText("HELLO",0,0,textPaint);
    3. textPaint.setARGB(255,255,0,0);
    4. c.drawText("This is some more text",0,20,textPaint);
    5. textPaint.setARGB(255,0,255,0);
    6. c.drawText("More text",0,40,textPaint);
    Or should I create 3 different Paint objects in memory and use them separately?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. fabiocberg

    fabiocberg Newbie

    Hi safibaba,
    You are using the native font from Android and I really recommend it.
    So, you don't need to create 3 different Paint objects, because to change color, size or font face, is really fast.
    You can use only one Paint object.
     
  3. safibaba

    safibaba Newbie
    Thread Starter

    Thanks fabio - will be much easier to use just one paint object. :)
     
Loading...

Share This Page

Loading...