SORU
20 Temmuz 2011, ÇARŞAMBA


Beraberlik satırı çok Tuval metin

Umarım hızlı bir soru, ama ben bulamıyorum herhangi bir örnek... ben yazmak ister çoklu satır metin için bir özel View) Canvas onDraw() var:

...
String text = "This is\nmulti-line\ntext";
canvas.drawText(text, 100, 100, mTextPaint);
...

Bu Satır sonları neden olacağını umuyordum, ama onun yerine \n olacağı şifreli karakterler görüyorum.

Herhangi bir işaretçiler takdir.

Paul

CEVAP
20 Temmuz 2011, ÇARŞAMBA


Her bir satır yineleme:

int x = 100, y = 100;
for (String line: text.split("\n")) {
      canvas.drawText(line, x, y, mTextPaint);
      y  = mTextPaint.descent() - mTextPaint.ascent();
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AutoklubZAPRESIC

    AutoklubZAPR

    17 Mayıs 2011
  • SuppressedStorm

    SuppressedSt

    11 AĞUSTOS 2013
  • Theodore Leaf

    Theodore Lea

    29 AĞUSTOS 2006