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...
Similar Threads - using Paint objects
  1. Gobshyte
    Replies:
    11
    Views:
    732
  2. timelinex
    Replies:
    13
    Views:
    450
  3. JaySantos
    Replies:
    1
    Views:
    574
  4. MartinPHP
    Replies:
    1
    Views:
    649
  5. h110m
    Replies:
    0
    Views:
    842
  6. toekneetv3
    Replies:
    1
    Views:
    2,033
  7. jo69
    Replies:
    9
    Views:
    1,537
  8. toziacl
    Replies:
    5
    Views:
    793
  9. hardik garg
    Replies:
    1
    Views:
    732
  10. batmandroid
    Replies:
    7
    Views:
    2,816

Share This Page

Loading...