Skip to content

Commit

Permalink
修复多行文本展示偏移问题
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanbin committed Mar 15, 2018
1 parent 39ebea4 commit ac1a0df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition
}
});
avatarColumn.setFixed(true);
Column < String > column4 = new Column<>("测试多重查询", "childData.child");
Column < String > column4 = new Column<>("测试多重查询", "childData.child",new MultiLineDrawFormat<String>(this,100));
column4.setAutoCount(true);
final IFormat<Long> format = new IFormat<Long>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ public void draw(Canvas c, Rect rect, CellInfo<T> cellInfo ,TableConfig config)
textPaint.setTextAlign(cellInfo.column.getTextAlign());
}
int hPadding = (int) (config.getHorizontalPadding()*config.getZoom());
int vPadding = (int) (config.getVerticalPadding()*config.getZoom());
int realWidth =rect.width() - 2*hPadding;
StaticLayout staticLayout = new StaticLayout(cellInfo.column.format(cellInfo.row), textPaint, realWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
c.save();
c.translate(DrawUtils.getTextCenterX(rect.left+hPadding,rect.right-hPadding,textPaint), rect.top+vPadding);
c.translate(DrawUtils.getTextCenterX(rect.left+hPadding,rect.right-hPadding,textPaint), rect.top+(rect.height()-staticLayout.getHeight())/2);
staticLayout.draw(c);
c.restore();
}
Expand Down

0 comments on commit ac1a0df

Please sign in to comment.