Android 如何将图片从资源和html加载到webview?

Android 如何将图片从资源和html加载到webview?,android,android-webview,android-resources,android-drawable,Android,Android Webview,Android Resources,Android Drawable,我希望webview显示来自资源的图片和来自数据库的html代码,但只有来自数据库的html代码工作正常 WebView wv = (WebView) findViewById(R.id.wv); String city = "lichtenstein"; String img = "<img src =\"file://res/drawable/picture.png\" width=\"100\" height=\"100\" />"; String dbHTML = curso

我希望webview显示来自资源的图片和来自数据库的html代码,但只有来自数据库的html代码工作正常

WebView wv = (WebView) findViewById(R.id.wv);
String city = "lichtenstein";
String img = "<img src =\"file://res/drawable/picture.png\" width=\"100\" height=\"100\" />";
String dbHTML = cursor.getString(cursor.getColumnIndex(Database.COLUMN_HTML));
String webdata = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />" + img + "<br />" + "<span style=\"color:#064896;font-weight:bold;\">" + city  + " </span>" + dbHTML;
wv.loadData(webdata, "text/html; charset=UTF-8", null);
WebView wv=(WebView)findviewbyd(R.id.wv);
字符串city=“lichtenstein”;
字符串img=“”;
String dbHTML=cursor.getString(cursor.getColumnIndex(Database.COLUMN_HTML));
字符串webdata=“”+img+”
“+”+city+”+dbHTML; wv.loadData(webdata,“text/html;charset=UTF-8”,null);
我还尝试使用资产文件夹中的图像,但也不起作用

String img = "<img src =\"file:///android_asset/picture.png\" width=\"100\" height=\"100\" />";
String img=”“;
您可以使用。

字符串htmlString=
myWebView.loadDataWithBaseURL(“file:///android_asset/,htmlString,“text/html”,“UTF-8”,null);
第一个参数必须指向图像必须位于的位置


我想用一些html文本在webview中设置bg,这可行吗?
String htmlString = <html><body><img src="file.png"></body></html>
myWebView.loadDataWithBaseURL("file:///android_asset/", htmlString, "text/html", "UTF-8", null);