3

The text I draw seems to be about the same size on a 10 inch screen and a 7 inch screen, thus it is not always lined up with the background, which is a bitmap. Is there a way to set the text size in pixcles

This is the code I have now

paint.setColor(Color.WHITE);  
paint.setTextSize(20); 
canvas.drawText("SETTINGS:", tx,ty, paint);
Ahmad
  • 69,608
  • 17
  • 111
  • 137
Ted pottel
  • 6,869
  • 21
  • 75
  • 134
  • 1
    The unit is pixels already. See this question: http://stackoverflow.com/questions/11720093/which-unit-of-measurement-does-the-paint-settextsizefloat-use – Lukas Knuth Sep 26 '13 at 23:14

1 Answers1

0

You can try this:

paint.setColor(Color.WHITE);  
paint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
canvas.drawText("SETTINGS:", tx,ty, paint);

Read more abaoute TypedValue

Att: The source is on this post.

Hope it helps ^^

Community
  • 1
  • 1
Cold
  • 787
  • 8
  • 23
  • Paint.setTextSize no such method with TypedValue. Use TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 12f, resources.displayMetrics) – maXp Jul 12 '19 at 09:49