TableHandler.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:SDHtmlTextView 作者:
@Override
public void draw(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(textColor);
    paint.setStyle(Style.STROKE);

    int numberOfColumns = tableRow.size();

    if (numberOfColumns == 0) {
        return;
    }

    int columnWidth = tableWidth / numberOfColumns;

    int offset = 0;

    for (int i = 0; i < numberOfColumns; i++) {

        offset = i * columnWidth;

              if ( paintBorder ) {
            // The rect is open at the bottom, so there's a single line
            // between rows.
            canvas.drawRect(offset, 0, offset + columnWidth, rowHeight,
                paint);
              }

        StaticLayout layout = new StaticLayout(tableRow.get(i),
                getTextPaint(), (columnWidth - 2 * PADDING),
                Alignment.ALIGN_NORMAL, 1f, 0f, true);

        canvas.translate(offset + PADDING, 0);
        layout.draw(canvas);
        canvas.translate(-1 * (offset + PADDING), 0);

    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号