自定义html视图以支持android textview中的图像。base64映像中的Web视图加载速度非常慢
我想使用nativescript的htmlview来渲染Base64编码的图像。有没有办法定制htmlview,因为有很多文章在android textview中提供对图像的支持,而nativesccript htmlview被包装在android textview中 我尝试过,使用了通过android的fromHtml方法插入base64图像的方法,但都不起作用。它显示[obj]而不是图像 getSafe(文本:字符串,视图:任意){ 让context=view.\u context自定义html视图以支持android textview中的图像。base64映像中的Web视图加载速度非常慢,android,nativescript,Android,Nativescript,我想使用nativescript的htmlview来渲染Base64编码的图像。有没有办法定制htmlview,因为有很多文章在android textview中提供对图像的支持,而nativesccript htmlview被包装在android textview中 我尝试过,使用了通过android的fromHtml方法插入base64图像的方法,但都不起作用。它显示[obj]而不是图像 getSafe(文本:字符串,视图:任意){ 让context=view.\u context let
let d = new android.text.Html.ImageGetter({
// @Override
getDrawable(source: string): android.graphics.drawable.Drawable {
let base_64_source: string = source.replace(/data.*base64/g, "");
const data = android.util.Base64.decode(
base_64_source,
android.util.Base64.DEFAULT
);
const bitmap: android.graphics.Bitmap = android.graphics.BitmapFactory.decodeByteArray(
data,
0,
data.length
);
let image: android.graphics.drawable.Drawable = new android.graphics.drawable.BitmapDrawable(
context.getResources(),
bitmap
);
image.setBounds(
0,
0,
0 + image.getIntrinsicWidth(),
0 + image.getIntrinsicHeight()
);
return image;
// return new android.graphics.drawable.BitmapDrawable(getResources(), bitmap);
}
});
图像显示为[OBJ]而非图像请共享自定义HtmlView的完整代码或游乐场示例。请共享自定义HtmlView的完整代码或游乐场示例。