今天后台返回富文本格式数据,找了一个第三方库
在build.gradle文件的dependencies中
implementation('com.github.sendtion:XRichText:1.5') {
exclude group: 'com.android.support'
exclude group: 'com.github.bumptech.glide'
}因为我用的sdk是26的必须配置下面两行代码,如果是27以上含27则不用写 exclude group: 'com.android.support'
exclude group: 'com.github.bumptech.glide'配置好后xml文件:写一个
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_note_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="false" />
</LinearLayout>
</ScrollView>Java文件中
RichText.from(guangbobean.data.content)
.imageClick(new OnImageClickListener() {
@Override
public void imageClicked(List<String> imageUrls, int position) {
Calendar calendar = Calendar.getInstance();
int m = calendar.get(Calendar.MINUTE);
int s = calendar.get(Calendar.SECOND);
}
}).into(tvNoteContent);
本文介绍了一种使用第三方库XRichText实现富文本显示的方法。针对Android SDK 26的环境,详细展示了如何排除不必要的依赖,并提供了具体的XML布局及Java代码示例。
2994

被折叠的 条评论
为什么被折叠?



