WebView is not filling the whole screen of device or emulator
Asked Answered
D

3

8

I am developing an android application which loads a web application when started. To achieve the purpose I am using webview control. I want my webview to be displayed full screen so that it will give native feel to the users. I tried all the methods to display webthview full screen but nothing is working. I dont know what I am missing. I need help on that. Below I am posting the code snippets that I tried also attached screenshots that shows how webview is displaying on emulator and mobile as well.

Method 1: Tried with simple basic code

    webbrowser.setWebViewClient(new MyWebViewClient());
    webbrowser.getSettings().setJavaScriptEnabled(true);
    webbrowser.loadUrl("http://google.com");

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

Method 2: Tried setting theme as full screen in manifest file

        <application android:icon="@drawable/icon" 
    android:label="@string/app_name"
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

Method 3: Tried doing it using code

//Full screen
requestWindowFeature(Window.FEATURE_NO_TITLE); 
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
WindowManager.LayoutParams.FLAG_FULLSCREEN);

Method 4: Tried with ChromeClient

mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
mWebView.loadUrl("http://google.com/");

Method 5: Tried just defining webview without layout in main.xml

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview_compontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
/>

Method 6: Also tried with relative layout by aligning webview edges to parent

Nothing worked for me. The device I am testing with is samsung galaxy tab and emulator is Android 2.3.3. In 7 inch galaxy tab it is showing up in the middle and on four sides there are blank spaces. Whereas in emulator its leaving space at the bottom.

I really appreciate if someone can guide me on this.

Disoblige answered 21/4, 2011 at 3:58 Comment(0)
K
9

just ad in manifest the following code:

>

<supports-screens android:smallScreens="true"
    android:normalScreens="true" android:largeScreens="true"
    android:anyDensity="true" />
Kilby answered 21/4, 2011 at 4:52 Comment(0)
I
0

mWebView.setWebChromeClient(new MyWebChromeClient());

remove this java code from your activity.java file then se,

Immobility answered 3/9, 2013 at 19:34 Comment(0)
I
0

just remove the padding from your layout...

Immobility answered 4/9, 2013 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.