1

I want to draw text in Canvas. using this code:

canvas.drawText(getString(R.string.test1)+c, 30,320, paint);

a need change of "c" to bold...

Thanks...

TT_from_KZ
  • 55
  • 1
  • 5
  • Only c? R.String.test1 is not supposed to be bold? –  Dec 29 '11 at 09:32
  • possible duplicate of [Is it possible to display multi-color text with one call to Canvas.drawText()?](http://stackoverflow.com/questions/10410515/is-it-possible-to-display-multi-color-text-with-one-call-to-canvas-drawtext) – Austyn Mahoney Apr 28 '15 at 22:54

2 Answers2

0

the class Paint has method setTypeface , you can pass a Typeface. code exmaple:

paint.setTypeface(Typeface.DEFAULT_BOLD);

so if you want change part of text, can draw one by one through change the typeface.

also, you can try use html code like <b>c</b>

idiottiger
  • 5,147
  • 2
  • 25
  • 21
0

Canvas.drawText and its various variants do all expect either a String, CharSequence or char[]. All those types do not support Spannable or Stylable objects. Short: It's not possible in the way you want.

You probably can try to implement the suggesstions idiottiger posted.

poitroae
  • 21,129
  • 10
  • 63
  • 81