How to make a full screen webview

后端 未结 7 855
离开以前
离开以前 2020-12-15 07:51

How to make the webview of an android application full screen. I have added the webview on a layout xml file but it doesn\'t stretches out till the edges of the layout, ther

相关标签:
7条回答
  • 2020-12-15 08:31

    Android Version: 4.2.2 - Device: Vega Tablet

    WebView to Hide Status and System Bar and displaying complete screen I followed these steps.

    AndroidManifest.xml

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    

    MainActivity.java

    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(0x10);
    setContentView(R.layout.activity_main);
    String url = "http://edition.cnn.com/";
    WebView webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUserAgentString("Desktop");
    webView.loadUrl(url);
    

    The above process worked for me and my app is displayed in complete screen.

    0 讨论(0)
提交回复
热议问题