Question: I am trying to embed a youtube video inside a webview and it seems there is a small margin on the right-side of the video which is not going away.

I saw many other Questions like these and tried fixing the javascript but still the margin is there.

Here is my code :

```
           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");

```

I tried giving the style:body=0'margin=0 tag inside the javascript . I don't know how to upload the screenshot as i am debugging on my phone but its a video with a margin of about 6pixels on the right of the video while the left hand side and the top of the video are aligned with the screen.

Answer: 
Well, HTML is left-aligned by default, so, in case you have a margin on the RIGHT hand side, this means that margin:0 worked. However, setting the right-hand side margin to 0 won't help as it doesn't mean the object would fill. 

Try to say

```
        + " type='application/x-shockwave-flash' style='margin:0;width:100%;padding:0;' allowscriptaccess='always' allowfullscreen='true'"

```

If setting width to 100% for the embed doesn't work, perhaps try to set the width to the device screen's width, and don't forget to update on orientation.
So after much researching and trying to figure out how it works i have this working code for whoever who might need it in the future :

```
            Display display = getActivity().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int widthdp = (int) (width / getResources().getDisplayMetrics().density);
    int height = display.getHeight();
    int heightdp = (int) (height / getResources().getDisplayMetrics().density);

    String widthAndHeight = "width=" + widthdp + "height=" + heightdp;

    String temp = "<object "
            + widthAndHeight
            + ">"
            + "<body style='margin:0;padding:0;'>"
            + "<param name='allowFullScreen' value='true'>"
            + "</param><param name='allowscriptaccess' value='always'>"
            + "</param><embed src='"
            + videoPoP
            + "'"
            + " type='application/x-shockwave-flash' style='margin:0;padding:0;' allowscriptaccess='always' allowfullscreen='true'"
            + widthAndHeight + "></embed></object>";

    video.loadData(temp, "text/html", "utf-8");

```

The problem was getting the width and the height for the screen would screw up the density pixels and normal pixalation problems.