android - How to set size of webview in WallpaperService? -
i'm trying set webview live wallpaper, have problem sizing it.
in engine create webview wallpaperservice's context:
public wallpaperengine(context context) { webview = new webview(context); ... }
and draw wallpaper's canvas:
surfaceholder holder = getsurfaceholder(); canvas canvas = null; try { canvas = holder.lockcanvas(); if (canvas != null) { webview.draw(canvas); } } { if (canvas != null) holder.unlockcanvasandpost(canvas); }
but wallpaper white , javascript reports, window's size 0px.
how set size of webview?
solved using windowmanager, defining size in layoutparams , changing webview visibility gone.
webview = new webview(context); webview.setvisibility(webview.gone); webview.loadurl("http://example.com/"); wm = (windowmanager)context.getsystemservice(window_service); params = new windowmanager.layoutparams( windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.wrap_content, windowmanager.layoutparams.type_phone, windowmanager.layoutparams.flag_not_touchable, pixelformat.translucent ); params.width = //width params.height = //height wm.addview(webview, params);
Comments
Post a Comment