4

I currently have a webview that displays a current site. However, it cuts off the side of the page. See the picture below. Is there anyway to fix this? See my code and xml below too. Thanks!

Picture:

enter image description here

Code:

    // create alert dialog
    blogDialog = new AlertDialog.Builder(BlogActivity.this).create();

    // add progress bar support
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    // make progress bar visible
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
            Window.PROGRESS_VISIBILITY_ON);

    setContentView(R.layout.webtab);

    sdrWebView = (WebView) findViewById(R.id.sdrwebview);
    sdrWebView.getSettings().setJavaScriptEnabled(true);

    // set web view zoom
    //sdrWebView.setInitialScale(scaleInPercent)

    // set the width,zoom function, and other settings
    sdrWebView.getSettings().setUseWideViewPort(true);
    //sdrWebView.getSettings().getUseWideViewPort(true);
    sdrWebView.setInitialScale(0);
    sdrWebView.getSettings().setBuiltInZoomControls(false);
    sdrWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    sdrWebView.canGoBack();
    sdrWebView.getSettings().setAllowFileAccess(true);
    sdrWebView.getCertificate();

    // remove scrollbar
    sdrWebView.setVerticalScrollBarEnabled(false);

    // set the URL
    sdrWebView.loadUrl("http://www.stopdroprave.com");

    //enable flash
    sdrWebView.getSettings().setJavaScriptEnabled(true);

XML:

<RelativeLayout 
android:id="@+id/relativeLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical">
  <WebView
        android:id="@+id/sdrwebview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</RelativeLayout>
Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
Splitusa
  • 1,181
  • 7
  • 31
  • 51

2 Answers2

2

From your picture it looks like you're also using Tabs. It's likely a result of the embedded webview not knowing its parents bounds properly and taking the width of the screen instead of the tab view.

You can fix this in a couple of ways, but probably the quickest/dirtiest way would be messing around with the margin of the webview to match that of your tab layout.

Andrew T.
  • 2,088
  • 1
  • 20
  • 42
2

Two possibilities here:

  1. Look if you got padding/margin in your parent view (the tabhost layout).

  2. Add following to your:

<supports-screens android:smallScreens="true"
      android:normalScreens="true" 
      android:largeScreens="true"
  android:anyDensity="true" />
Warpzit
  • 27,966
  • 19
  • 103
  • 155