利用canvas画text时的换行实现
来源:互联网 发布:ahc淘宝旗舰店真的吗 编辑:程序博客网 时间:2024/06/07 23:08
private void drawText(String str,Paint pa,Canvas ca) {
float[] widths ;
float toalwidth = 0 ;
int mTextXPoint = 10 ; //text的起始点X
int mTextYPoint = 10 ; //text的起始点Y
widths = new float[50];
int index = 0;
int count = 1 ;
float height = pa.getTextSize();
pa.getTextWidths(str, widths);
for(int i=0 ;i< 50 ;i++) {
Log.e(TAG, "toalwidth =" + toalwidth);
toalwidth = toalwidth + widths[i] ;
if((( mWidth -20 ) < toalwidth) || (widths[i] == 0)) {
String text = str.substring(index, i);
Log.e(TAG, "text =" + text +" i=" +i +" index=" +index);
index = i;
if(toalwidth >( mWidth -20 ) ) {
ca.drawText(text, mTextXPoint , mTextYPoint + count *(height + 10), pa);
}else
ca.drawText(text, (mWidth - toalwidth )/2 , mTextYPoint + count *(height + 10), pa);//mWidth 是屏幕的宽度。保证居中
count ++ ;
toalwidth = 0 ;
if(widths[i] == 0)
return ;
}
}
}
- 利用canvas画text时的换行实现
- 利用CSS3 text-overflow换行
- android中画文字的换行 办法(对于遇到canvas.drawText(String s )无法实现换行问题的解决)
- android中画文字的换行 办法(对于遇到canvas.drawText(String s )无法实现换行问题的解决
- android中画文字的换行 办法(对于遇到canvas.drawText(String s )无法实现换行问题的解决)
- android中画文字的换行 办法(对于遇到canvas.drawText(String s )无法实现换行问题的解决)
- 利用canvas实现的JS画圆圈特效代码
- 利用canvas实现折线图的绘制
- canvas的文字自动换行
- android 使用canvas画字符时,常常遇到字符很长,不会换行的问题.
- 利用HTML5的canvas标签实现灰太狼图像的绘制
- 利用canvas实现鼠标拖拽效果的一种方法
- 利用jQuery.print.js实现canvas的打印功能
- svg中text换行,vml里面textbox实现换行
- canvas text
- j2me在Canvas上绘制大量文本自动换行的实现
- html5-canvas的绘制文本自动换行
- HTML5 canvas 绘制的文字如何换行?
- 火狐浏览器和IE的CSS区别
- Launcher 类及类关系分析
- ARM立即数,LDR和MOV的区别
- gdb调试,显示utf-8字符
- java访问WebService接口返回xml
- 利用canvas画text时的换行实现
- WordPress中如何实现Ping功能
- 智能常识 ROM RAM
- 比较StreamReader的read()与FileStream的read()
- 关于C#中的StreamReader与FileStream这两个类
- 原型 模式
- 转!转!转! 白师傅的 嗯 受教
- Android uses-permission大全
- jquery.autocomplete.js 参数属性介绍