1.9 KiB
Tables
This extension adds support for GFM tables.
final Markwon markwon = Markwon.builder(context)
// create default instance of TablePlugin
.usePlugin(TablePlugin.create(context))
final TableTheme tableTheme = TableTheme.builder()
.tableBorderColor(Color.RED)
.tableBorderWidth(0)
.tableCellPadding(0)
.tableHeaderRowBackgroundColor(Color.BLACK)
.tableEvenRowBackgroundColor(Color.GREEN)
.tableOddRowBackgroundColor(Color.YELLOW)
.build();
final Markwon markwon = Markwon.builder(context)
.usePlugin(TablePlugin.create(tableTheme))
Please note, that by default tables have limitations. For example, there is no support for images inside table cells. And table contents won't be copied to clipboard if a TextView has such functionality. Table will always take full width of a TextView in which it is displayed. All columns will always be the of the same width. So, default implementation provides basic functionality which can answer some needs. These all come from the limited nature of the TextView to display such content.
In order to provide full-fledged experience, tables must be displayed in a special widget.
Since version 3.0.0
Markwon provides a special artifact markwon-recycler
that allows
to render markdown in a set of widgets in a RecyclerView. It also gives ability to change
display widget form TextView to any other.
final Table table = Table.parse(Markwon, TableBlock);
myTableWidget.setTable(table);
Unfortunately Markwon does not provide a widget that can be used for tables. But it does provide API that can be used to achieve desired result.