首页 > 其他 > 详细

canvas实现文字分行

时间:2016-03-27 15:40:57      阅读:210      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!