2

I want to my webview to fit the screen ,now there is a small empty border along the webview (not coming full screen). how to make my webview to fit screen by using xml code enter image description here

  <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="com.fb.jaisonjoseph.facebookbasic.Home_Fragment">

  <!-- TODO: Update blank fragment layout -->


  <WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/webView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true" />
    </RelativeLayout>
Jaison_Joseph
  • 333
  • 7
  • 26

4 Answers4

2

You simply add this in your parent layout:

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView" />
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
1

The problem that you are having is most likely because your activity_main probably still has the preset padding that is put in when you first create an Application. This is a code example I made and it worked on full Screen:

MainActivity.java

activity_main.xml

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
0

Replace your WebView code with this one

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_margin="0dp"
    android:padding="0dp"/>

I think this code change works for you

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
ndroid:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity" >

in xml file, change activity padding to "0dp" and change webview to fill_parent or match_parent.