Markwon
Markwon copied to clipboard
If the width of the TextView is set to wrap_content, the table cannot be displayed.
- Markwon version: {4.6.2}
The width of the TextView is set to wrap_content:
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingExtra="2dip"
android:padding="@dimen/content_padding_double"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary"
tools:text="Hello there" />
The table cannot be displayed:
public class TableCustomizeSample extends MarkwonTextViewSample {
@Override
public void render() {
final String md = "" +
"| HEADER | HEADER | HEADER |\n" +
"|:----:|:----:|:----:|\n" +
"| 测试 | 测试 | 测试 |\n" +
"| 测试 | 测试 | 测测测12345试测试测试 |\n" +
"| 测试 | 测试 | 123445 |\n" +
"| 测试 | 测试 | (650) 555-1212 |\n" +
"| 测试 | 测试 | [link](#) |\n";
final Markwon markwon = Markwon.builder(context)
.usePlugin(TablePlugin.create(builder -> {
final Dip dip = Dip.create(context);
builder
.tableBorderWidth(dip.toPx(2))
.tableBorderColor(Color.YELLOW)
.tableCellPadding(dip.toPx(4))
.tableHeaderRowBackgroundColor(ColorUtils.applyAlpha(Color.RED, 80))
.tableEvenRowBackgroundColor(ColorUtils.applyAlpha(Color.GREEN, 80))
.tableOddRowBackgroundColor(ColorUtils.applyAlpha(Color.BLUE, 80));
}))
.build();
markwon.setMarkdown(textView, md);
}
}