Android ApiDemos示例解析(84):Graphics->UnicodeChart
程序员文章站
2022-07-16 08:28:01
...
本例没有介绍什么新知识,只是指屏幕上每页显示256个字符,使用“左”,“右”方向键来翻页。
每页绘制的代码如下:
private void drawChart(Canvas canvas, int base) { char[] chars = mChars; for (int i = 0; i < 256; i++) { int unichar = base + i; chars[i] = (char)unichar; canvas.drawText(Integer.toHexString(unichar), computeX(i), computeY(i), mLabelPaint); } canvas.drawPosText(chars, 0, 256, mPos, mBigCharPaint); }
通过(char) 将整数强制转化为字符,然后调用drawPosText绘制字符串。
推荐阅读
-
Android ApiDemos示例解析(19):App->Alarm->Alarm Controller
-
Android ApiDemos示例解析(19):App->Alarm->Alarm Controller
-
Android ApiDemos示例解析(20):App->Alarm->Alarm Service
-
Android ApiDemos示例解析(84):Graphics->UnicodeChart
-
Android ApiDemos示例解析(83):Graphics->Typefaces
-
Android ApiDemos示例解析(83):Graphics->Typefaces
-
Android ApiDemos示例解析(85):Graphics->Vertices
-
Android ApiDemos示例解析(21):App->Device Admin
-
Android ApiDemos示例解析(21):App->Device Admin
-
Android ApiDemos示例解析(84):Graphics->UnicodeChart