0

I've searched the internet and found out that if we want to change the text color of paint I must use setColor(). It also works for the set background too. I want to change both text color and background when the user selects a special cell in my application. setColor() is use for both?

this my code:

  Paint p = new Paint();

  case Connected:
            p.setColor(Color.WHITE);
            p.setColor(getResources().getColor(R.color.intro_txt_cell_color)); // here I change background
        
            if (mGameCell.isFixed()) {
                p.setAlpha(140);

            } else {
                p.setAlpha(90);
            }
            drawBackground(canvas, 3, 3, mWidth - 3, mHeight - 3, p);
            break;

When I add set color again, it changes my background. How can I change both text color and background?

aminography
  • 21,986
  • 13
  • 70
  • 74
nsr
  • 115
  • 13
  • check this it may help u https://stackoverflow.com/questions/18934875/android-canvas-fill-background-color-canvas-application – Abdulkarim Aug 22 '20 at 23:56
  • If you want to draw a background shape with a specific color in addition to a text with another color, you should use two different `Paint` objects for them. – aminography Aug 23 '20 at 05:11

0 Answers0