android studio中新建assets,用webview加载本地图片

xml文件中创建webview

	/>

在project下,main文件夹下新建assets文件,建web,最后images,在images里放需要加载的图片,在web中加入以该图片命名的html,其代码为:



explain







最后在主代码里,申明webview,加入以下代码:

WebSettings webSettings = wvExplain.getSettings();
        webSettings.setBuiltInZoomControls(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);
        wvExplain.getSettings().setSupportZoom(true);
        wvExplain.setBackgroundColor(Color.TRANSPARENT);
        wvExplain.loadUrl("file:///android_asset/web/explain.html");

至此,好像是可以了吧?

你可能感兴趣的:(android,studio,assets,web,html,images)