繁体   English   中英

如何在android studio中的webview内画一条线

[英]how to draw a line inside webview in android studio

下面的代码在我的webview中给了我位图

Bitmap bitmap = bm;
String html="<html><body><img src='dicomFile' /></body></html>";

// Convert bitmap to Base64 encoded image for web
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
String imgageBase64 = Base64.encodeToString(byteArray, Base64.DEFAULT);
String image = "data:image/png;base64," + imgageBase64;


// Use image for the img src parameter in your html and load to webview
html = html.replace("dicomFile", image);
imageView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", "");
imageView.getSettings().setBuiltInZoomControls(true);

我尝试使用下面的代码在webview内绘制线条,但不起作用

paint=new Paint();
canvas.drawLine(50,128, 300, 128, paint);
imageView.draw(canvas);

现在我需要在此图像内画线。这怎么可能?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM