How to make a full screen webview

后端 未结 7 854
离开以前
离开以前 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:14

    From above code remove padding tags -

    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    

    It will do the job and also be sure to remove the HTML's margins/padding which you are rendering into the WebView that might contain those tags which leaves some space.

    0 讨论(0)
  • 2020-12-15 08:16

    You can set dimensions in dimens.xml found in res/values folder. By default it is 16dp. So can set it accordingly.

    enter image description here

    0 讨论(0)
  • 2020-12-15 08:21

    From the docs https://developer.android.com/guide/webapps/webview.html

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

    FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding)

    https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html

    0 讨论(0)
  • 2020-12-15 08:24

    Put webview in to dialog popup window.

    WebView webview = new WebView(this/*put your activity object*/);
        webview.getSettings().setLoadWithOverviewMode(true);
        webview.getSettings().setUseWideViewPort(false);
        webview.getSettings().setSupportZoom(false);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.setBackgroundColor(Color.TRANSPARENT);
        webview.loadUrl("http://www.awwwards.com/websites/responsive-design/");
    
        RelativeLayout.LayoutParams paramsWebView = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        Dialog dialog = new Dialog(this/*put your activity object*/, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        dialog.addContentView(webview, paramsWebView);
        dialog.show();
    
    0 讨论(0)
  • You should change the relative layout settings. And remove padding settings, if any on webview on XML file.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity"
        android:id="@+id/frame">

    0 讨论(0)
  • 2020-12-15 08:29

    Just add (or change) the activity's android:theme attribute with following line in AndroidManifest.xml file

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    
    0 讨论(0)
提交回复
热议问题