我正在使用绕过lib来解析markdown字符串以在TextView中显示。 基本上这个lib的作用是解析所有字符串并构建一个SpannedString以在TextView中显示它。我已经对所有的lib代码进行了调试,并且无法在合理的时间内找到出错的地方。是否有人遇到过同样的问题并可以帮助我?
String markdownStr = "# Testing Markdown\n" +
"\n" +
"![surf](http://www.adesl.pt/images/outras-provas/surf.jpg)";
TextView markdownTxtView = (TextView) findViewById(R.id.markdown);
Bypass bypass = new Bypass(getApplicationContext());
CharSequence charSequence = bypass.markdownToSpannable(markdownStr, new Bypass.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
//TODO: get drawable from source
Drawable drawable = getApplicationContext().getResources().getDrawable(R.drawable.test);
return drawable;
}
});
markdownTxtView.setText(charSequence);
答案 0 :(得分:0)
通过添加波纹管代码,它可以工作:
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
Picasso Image Getter https://github.com/Commit451/BypassPicassoImageGetter
Glide Image Getter https://github.com/victorlaerte/BypassGlideImageGetter