// 本方法 分行又分页public static ArrayList<ArrayList<String>> getPageContentStringInfo(    Paint m_paint, String content, int pageLines, float pageWidth) {   char ch;   int w = 0;   int istart = 0;   int lineNum = 0;   ArrayList<ArrayList<String>> contentList = new ArrayList<ArrayList<String>>();   ArrayList<String> cl = null;   // 内容长度   for (int i = 0; i < content.length(); i++) {    if (cl == null)     cl = new ArrayList<String>();    ch = content.charAt(i);    float[] widths = new float[1];    String srt = String.valueOf(ch);    m_paint.getTextWidths(srt, widths);    if (ch == '\n') {     // 如果遇到断行符     lineNum++;     cl.add(content.substring(istart, i));     istart = i + 1;     w = 0;    } else {     // 遇到字符     w += (int) (Math.ceil(widths[0]));     // 当长度小于宽度时     if (w > pageWidth) {      lineNum++;      cl.add(content.substring(istart, i));      istart = i;      i--;      w = 0;     } else {      if (i == (content.length() - 1)) {       lineNum++;       cl.add(content.substring(istart, content.length()));      }     }    }    if (lineNum == pageLines || i == (content.length() - 1)) {     contentList.add(cl);     System.out.println(cl.toString());     cl = null;     // 当最后一个字符时的行数     lines = lineNum;     lineNum = 0;    }   }   return contentList; } 

更多相关文章

  1. Android EditText插入字符串到光标所在位置和删除
  2. android非法字符的判定、表情符号的判定
  3. Android将获取到文件的uri转换为字符串的路径
  4. android XML文件常用字符转义
  5. Android 创建一个包含星期的格式字符串
  6. Android源码快速查找文件、搜索字符串和编译
  7. android上传图片以及POST字符串
  8. android调用webservice方法,参数和返回值都用字符串
  9. android 发送短信 判断号码规则 判断字符数70

随机推荐

  1. 基于数据库实现分布式锁
  2. 【tomcat】使用jks配置https
  3. 基于单节点redis实现分布式锁
  4. 【springboot】使用redisson分布式锁
  5. 【redis】有关redis面试那些事(一)
  6. 【redis】使用redis位图轻松实时统计日活
  7. 5G消息要来了,你们期待吗?
  8. 【java】说说有关jdk动态代理的那些事
  9. 【mysql】ipv4地址转换为4字节整数
  10. 有关Apache dubbo反序列化漏洞的复现及思