我想以表格格式分享钻石详细信息(纯文本而不是 HTML
)
我用这个library做了这个但它使用 system.out 正确打印数据,但当我共享它时,它的格式发生了变化:
下面是我的代码:
List<String> headersList = Arrays.asList("", "");
List<List<String>> rowsList = Arrays.asList(
Arrays.asList("Stone Id :", details[0]),
Arrays.asList("Lab", details[1]),
Arrays.asList("Shape", details[2]),
Arrays.asList("Carat", details[3]),
Arrays.asList("Clarity-Color", details[4]),
Arrays.asList("Cut-Pol-Sym-Flou", details[5]));
Board board = new Board(75);
Table table = new Table(board, 75, headersList, rowsList);
table.invalidate().setGridMode(Table.GRID_NON).setRowsList(rowsList);
List<Integer> colWidthsList = Arrays.asList(30, 14);
table.setColWidthsList(colWidthsList);
Block tableBlock = table.tableToBlocks();
board.setInitialBlock(tableBlock);
board.build();
String preview1 = board.getPreview();
System.out.print(preview1);
sharingIntent.putExtra(Intent.EXTRA_TEXT,preview1);
最佳答案
控制台使用等宽字体,所有字符的宽度完全相同。但你的 View 没有使用它,所以它看起来很困惑。
使用等宽字体。
或者使用表格格式。也许是一个 ListView,每行都有两个并排的 TextView ,宽度固定。
关于java - 共享数据时文本格式发生更改 : Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46601048/