Search code examples
androidxmlandroid-studiowebviewnavigation-drawer

White Bar on LEFT of webview


I am getting a solid white bar on the LEFT side of my webview from a fragment. I have seen examples where the bar was on the right but not on the left. I have tried every solution from those examples such as

mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

or

mWebView.setVerticalScrollBarEnabled(false);

and within the XML layout setting scrollbars to

android:scrollbars="none"

Is there any way of removing this white bar? Additionally I have a navigation drawer on the left that I believe could be associated with the issue.

[white bar on the LEFT]

WebFragment.java

public class WebFragment extends Fragment implements IOBackPressed {

public WebView mWebView;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_shop, container, false);
    mWebView = (WebView) view.findViewById(R.id.webview);

    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // Force links and redirects to open in the WebView instead of in a browser
    mWebView.setWebViewClient(new myWebViewClient());
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setScrollBarSize(0);

    mWebView.loadUrl("");
    return view;
}

@Override
public boolean onBackPressed() {
    if (mWebView.canGoBack()) {
        mWebView.goBack();
        //backpress is not considered in the activity
        return true;
    } else {
        return false;
    }
}

}


Solution

  • I have checked your code , use this code before return view statement ,it will work fine .

        mWebView.getSettings().setLoadWithOverviewMode(true);
        mWebView.getSettings().setUseWideViewPort(true);