1. Download our Official Android App: Forums for Android!

Apps Re-using Paint objects?

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

  1. safibaba

    safibaba Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    May 3, 2010

    May 3, 2010
    15
    0
    15
    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?
     

    Advertisement

  2. fabiocberg

    fabiocberg Newbie
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    Apr 7, 2010

    Apr 7, 2010
    27
    1
    16
    Programmer (Coordinator)
    Brazil
    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
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    May 3, 2010

    May 3, 2010
    15
    0
    15
    Thanks fabio - will be much easier to use just one paint object. :)
     

Share This Page

Loading...