After numerous attempts to embed a YouTube video in a WebView, I'm still struggling with a persistent small margin on the right side of the video.
I've researched similar issues and attempted to address it through JavaScript adjustments without success.
Below is my current code snippet:
video = (WebView) v.findViewById(R.id.videoview);
// video.getSettings().setLoadWithOverviewMode(true);
// video.getSettings().setUseWideViewPort(true);
String widthAndHeight = "width='null' height='null'";
String videoURL = "http://www.youtube.com/v/DZi6DEJsOJ0";
video.setHorizontalScrollBarEnabled(false);
video.setVerticalScrollBarEnabled(false);
video.getSettings().setJavaScriptEnabled(true);
video.getSettings().setPluginsEnabled(true);
String temp = "<object "
+ widthAndHeight
+ ">"
+ "<body style='margin:0;padding:0;rightmargin:0'>"
+ "<param name='allowFullScreen' value='true'>"
+ "</param><param name='allowscriptaccess' value='always'>"
+ "</param><embed src='"
+ videoURL
+ "'"
+ " type='application/x-shockwave-flash' style='margin:0;padding:0;' allowscriptaccess='always' allowfullscreen='true'"
+ widthAndHeight + "></embed></object>";
video.loadData(temp, "text/html", "utf-8");
In attempting to resolve this issue, I included the 'style: body=0'margin=0' tag within the JavaScript. Unfortunately, due to debugging on my phone, I am unable to provide a screenshot. However, the video appears with a margin of approximately 6 pixels on the right side while the left side and top remain aligned with the screen.