Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a full screen webview

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, there is some type of margin along all the side of the webview. I am also adding an image to give you guys a hint on what actually it is looking like.

What i am talking about is the space all around the webview, not the notification bar or the title bar

What i am talking about is the space all around the webview, not the notification bar or the title bar

Here's the layout code:

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".WebView" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Shake / Tilt Your Phone To Get Accelerometer Motion Alerts" />

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

</RelativeLayout>
like image 525
Arihant Avatar asked Nov 24 '13 19:11

Arihant


People also ask

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

How do I zoom out in WebView Android?

webview. getSettings(). setLoadWithOverviewMode(true); This will cause the webview to be zoomed out initially.

What is the WebView layout on Android?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.

How can I improve my WebView performance?

I read about how to increase performance of WebView by implementing Caching web resources like JS, CSS and image files. You can also static resources in your native application, and by intercepting the Resource requests you can override the default behaviour of WebView.


1 Answers

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.

like image 112
VishalKale Avatar answered Sep 30 '22 16:09

VishalKale