码迷,mamicode.com
首页 > 其他好文 > 详细

canvas实现文字分行

时间:2016-03-27 15:42:34      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

//paint.setColor(Color.WHITE);//paint.setTextSize(TEXT_SIZE*density);//paint.setAlpha(0x40);//paint.setTypeface(Typeface.create("System",Typeface.BOLD));//canvas.drawText("将大象单车上的二维码放入框内\n获取开锁密码", frame.left, 、、//(float(frame.bottom + (float)TEXT_PADDING_TOP *density), paint);

将原来代码中的文字显示改为以下代码?

?TextPaint textPaint =new TextPaint();

?textPaint.setARGB(0xFF,255,251,240);

?textPaint.setTextSize(TEXT_SIZE * density);

?textPaint.setAntiAlias(true);

StaticLayout layout = new StaticLayout("将大象单车上的二维码放入框内\r\n获取开锁密码", textPaint,480,Layout.Alignment.ALIGN_CENTER, 1.0F, 0.0F, true);

canvas.save();

canvas.translate(frame.left,frame.bottom + (float)TEXT_PADDING_TOP *density);//从扫描匡下开始画

layout.draw(canvas);

?canvas.restore()

;//别忘了restore

 

技术分享

canvas实现文字分行

标签:

原文地址:http://www.cnblogs.com/rainhome/p/5325661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!