Android. Fit webview size to youtube video size -
i'd play youtube video using android webview. but want fit webview youtube video size. until now, implementaion below.
string vid = textutils.extractyoutubevid(body); if (stringutils.isblank(vid)) { return null; } string html = "<html > <head></head> <body style=\"margin:0 0 0 0; padding:0 0 0 0;\"> <iframe width=\"100%\" height=\"100%\" src=\"http://www.youtube.com/embed/___\" frameborder=\"0\"></iframe> </body> </html> "; html = html.replace("___", vid); mimportedvideowebview.setwebchromeclient(new webchromeclient()); websettings websettings = mimportedvideowebview.getsettings(); websettings.setjavascriptenabled(true); mimportedvideowebview.loaddata(html, "text/html", "utf-8");
mimportedvideowebview webview , width match_parent , height 350dp.
by using above code, can play youtube video.
but, want put webview width screen width , fit webview's height youtube video height proportionally. me plz!
thanks!
you can use:
webview.getsettings().setloadwithoverviewmode(true); webview.getsettings().setusewideviewport(true);
Comments
Post a Comment