to top
Android APIs
public abstract class

WebSettings

extends Object
java.lang.Object
   ↳ android.webkit.WebSettings

Class Overview

Manages settings state for a WebView. When a WebView is first created, it obtains a set of default settings. These default settings will be returned from any getter call. A WebSettings object obtained from WebView.getSettings() is tied to the life of the WebView. If a WebView has been destroyed, any method call on WebSettings will throw an IllegalStateException.

Summary

Nested Classes
enum WebSettings.LayoutAlgorithm Enum for controlling the layout of html. 
enum WebSettings.PluginState The plugin state effects how plugins are treated on a page. 
enum WebSettings.RenderPriority  
enum WebSettings.TextSize This enum is deprecated. Use setTextZoom(int) and getTextZoom() instead.  
enum WebSettings.ZoomDensity Enum for specifying the WebView's desired density. 
Constants
int LOAD_CACHE_ELSE_NETWORK Use cache if content is there, even if expired (eg, history nav).
int LOAD_CACHE_ONLY Don't use the network, load from cache only.
int LOAD_DEFAULT Default cache usage pattern.
int LOAD_NORMAL Normal cache usage pattern.
int LOAD_NO_CACHE Don't use the cache, load from network.
Public Methods
boolean enableSmoothTransition()
Gets whether the WebView enables smooth transition while panning or zooming.
boolean getAllowContentAccess()
Gets whether this WebView supports content URL access.
boolean getAllowFileAccess()
Gets whether this WebView supports file access.
abstract boolean getAllowFileAccessFromFileURLs()
Gets whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs.
abstract boolean getAllowUniversalAccessFromFileURLs()
Gets whether JavaScript running in the context of a file scheme URL can access content from any origin.
synchronized boolean getBlockNetworkImage()
Gets whether the WebView does not load image resources from the network.
synchronized boolean getBlockNetworkLoads()
Gets whether the WebView does not load any resources from the network.
boolean getBuiltInZoomControls()
Gets whether the zoom mechanisms built into WebView are being used.
int getCacheMode()
Gets the current setting for overriding the cache mode.
synchronized String getCursiveFontFamily()
Gets the cursive font family name.
synchronized boolean getDatabaseEnabled()
Gets whether the database storage API is enabled.
synchronized String getDatabasePath()
Gets the path to where database storage API databases are saved for the current WebView.
synchronized int getDefaultFixedFontSize()
Gets the default fixed font size.
synchronized int getDefaultFontSize()
Gets the default font size.
synchronized String getDefaultTextEncodingName()
Gets the default text encoding name.
WebSettings.ZoomDensity getDefaultZoom()
Gets the default zoom density of the page.
boolean getDisplayZoomControls()
Gets whether the WebView displays on-screen zoom controls when using the built-in zoom mechanisms.
synchronized boolean getDomStorageEnabled()
Gets whether the DOM Storage APIs are enabled.
synchronized String getFantasyFontFamily()
Gets the fantasy font family name.
synchronized String getFixedFontFamily()
Gets the fixed font family name.
synchronized boolean getJavaScriptCanOpenWindowsAutomatically()
Gets whether JavaScript can open windows automatically.
synchronized boolean getJavaScriptEnabled()
Gets whether JavaScript is enabled.
synchronized WebSettings.LayoutAlgorithm getLayoutAlgorithm()
Gets the current layout algorithm.
boolean getLightTouchEnabled()
Gets whether light touches are enabled.
boolean getLoadWithOverviewMode()
Gets whether this WebView loads pages with overview mode.
synchronized boolean getLoadsImagesAutomatically()
Gets whether the WebView loads image resources.
synchronized int getMinimumFontSize()
Gets the minimum font size.
synchronized int getMinimumLogicalFontSize()
Gets the minimum logical font size.
boolean getNavDump()
This method is deprecated. This method is now obsolete.
synchronized WebSettings.PluginState getPluginState()
Gets the current plugin state.
synchronized boolean getPluginsEnabled()
This method is deprecated. This method has been replaced by getPluginState()
synchronized String getPluginsPath()
This method is deprecated. This method is no longer used as plugins are loaded from their own APK via the system's package manager.
synchronized String getSansSerifFontFamily()
Gets the sans-serif font family name.
boolean getSaveFormData()
Gets whether the WebView is saving form data and displaying prior entries/autofill++.
boolean getSavePassword()
Gets whether the WebView is saving password.
synchronized String getSerifFontFamily()
Gets the serif font family name.
synchronized String getStandardFontFamily()
Gets the standard font family name.
synchronized WebSettings.TextSize getTextSize()
This method is deprecated. Use getTextZoom() instead.
synchronized int getTextZoom()
Gets the text zoom of the page in percent.
synchronized boolean getUseDoubleTree()
This method is deprecated. This setting now has no effect.
boolean getUseWebViewBackgroundForOverscrollBackground()
This method is deprecated. This method is now obsolete.
synchronized boolean getUseWideViewPort()
Gets whether the WebView is using a wide viewport.
synchronized int getUserAgent()
This method is deprecated. Please use getUserAgentString instead.
synchronized String getUserAgentString()
Gets the WebView's user-agent string.
void setAllowContentAccess(boolean allow)
Enables or disables content URL access within WebView.
void setAllowFileAccess(boolean allow)
Enables or disables file access within WebView.
abstract void setAllowFileAccessFromFileURLs(boolean flag)
Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs.
abstract void setAllowUniversalAccessFromFileURLs(boolean flag)
Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin.
synchronized void setAppCacheEnabled(boolean flag)
Tells the WebView to enable Application Caches API.
synchronized void setAppCacheMaxSize(long appCacheMaxSize)
Sets the maximum size for the Application Caches content.
synchronized void setAppCachePath(String appCachePath)
Sets a custom path to the Application Caches files.
synchronized void setBlockNetworkImage(boolean flag)
Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes).
synchronized void setBlockNetworkLoads(boolean flag)
Sets whether the WebView should not load resources from the network.
void setBuiltInZoomControls(boolean enabled)
Sets whether the WebView should use its built-in zoom mechanisms.
void setCacheMode(int mode)
Overrides the way the cache is used.
synchronized void setCursiveFontFamily(String font)
Sets the cursive font family name.
synchronized void setDatabaseEnabled(boolean flag)
Sets whether the database storage API is enabled.
synchronized void setDatabasePath(String databasePath)
Sets the path to where database storage API databases should be saved.
synchronized void setDefaultFixedFontSize(int size)
Sets the default fixed font size.
synchronized void setDefaultFontSize(int size)
Sets the default font size.
synchronized void setDefaultTextEncodingName(String encoding)
Sets the default text encoding name to use when decoding html pages.
void setDefaultZoom(WebSettings.ZoomDensity zoom)
Sets the default zoom density of the page.
void setDisplayZoomControls(boolean enabled)
Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms.
synchronized void setDomStorageEnabled(boolean flag)
Sets whether the DOM storage API is enabled.
void setEnableSmoothTransition(boolean enable)
Sets whether the WebView will enable smooth transition while panning or zooming or while the window hosting the WebView does not have focus.
synchronized void setFantasyFontFamily(String font)
Sets the fantasy font family name.
synchronized void setFixedFontFamily(String font)
Sets the fixed font family name.
synchronized void setGeolocationDatabasePath(String databasePath)
Sets the path where the Geolocation permissions database should be saved.
synchronized void setGeolocationEnabled(boolean flag)
Sets whether Geolocation is enabled.
synchronized void setJavaScriptCanOpenWindowsAutomatically(boolean flag)
Tells JavaScript to open windows automatically.
synchronized void setJavaScriptEnabled(boolean flag)
Tells the WebView to enable JavaScript execution.
synchronized void setLayoutAlgorithm(WebSettings.LayoutAlgorithm l)
Sets the underlying layout algorithm.
void setLightTouchEnabled(boolean enabled)
Enables using light touches to make a selection and activate mouseovers.
void setLoadWithOverviewMode(boolean overview)
Sets whether the WebView loads a page with overview mode.
synchronized void setLoadsImagesAutomatically(boolean flag)
Sets whether the WebView should load image resources.
synchronized void setMinimumFontSize(int size)
Sets the minimum font size.
synchronized void setMinimumLogicalFontSize(int size)
Sets the minimum logical font size.
void setNavDump(boolean enabled)
This method is deprecated. This method is now obsolete.
void setNeedInitialFocus(boolean flag)
Tells the WebView whether it needs to set a node to have focus when requestFocus(int, android.graphics.Rect) is called.
synchronized void setPluginState(WebSettings.PluginState state)
Tells the WebView to enable, disable, or have plugins on demand.
synchronized void setPluginsEnabled(boolean flag)
This method is deprecated. This method has been deprecated in favor of setPluginState(WebSettings.PluginState)
synchronized void setPluginsPath(String pluginsPath)
This method is deprecated. This method is no longer used as plugins are loaded from their own APK via the system's package manager.
synchronized void setRenderPriority(WebSettings.RenderPriority priority)
Sets the priority of the Render thread.
synchronized void setSansSerifFontFamily(String font)
Sets the sans-serif font family name.
void setSaveFormData(boolean save)
Sets whether the WebView is saving form data.
void setSavePassword(boolean save)
Stores whether the WebView is saving password.
synchronized void setSerifFontFamily(String font)
Sets the serif font family name.
synchronized void setStandardFontFamily(String font)
Sets the standard font family name.
synchronized void setSupportMultipleWindows(boolean support)
Tells the WebView whether it supports multiple windows.
void setSupportZoom(boolean support)
Sets whether the WebView should support zooming using its on-screen zoom controls and gestures.
synchronized void setTextSize(WebSettings.TextSize t)
This method is deprecated. Use setTextZoom(int) instead.
synchronized void setTextZoom(int textZoom)
Sets the text zoom of the page in percent.
synchronized void setUseDoubleTree(boolean use)
This method is deprecated. This setting now has no effect.
void setUseWebViewBackgroundForOverscrollBackground(boolean view)
This method is deprecated. This method is now obsolete.
synchronized void setUseWideViewPort(boolean use)
Tells the WebView to use the wide viewport.
synchronized void setUserAgent(int ua)
This method is deprecated. Please use setUserAgentString instead.
synchronized void setUserAgentString(String ua)
Sets the WebView's user-agent string.
synchronized boolean supportMultipleWindows()
Gets whether the WebView is supporting multiple windows.
boolean supportZoom()
Gets whether the WebView supports zoom.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int LOAD_CACHE_ELSE_NETWORK

Since: API Level 1

Use cache if content is there, even if expired (eg, history nav). If it is not in the cache, load from network. Use with setCacheMode(int).

Constant Value: 1 (0x00000001)

public static final int LOAD_CACHE_ONLY

Since: API Level 1

Don't use the network, load from cache only. Use with setCacheMode(int).

Constant Value: 3 (0x00000003)

public static final int LOAD_DEFAULT

Since: API Level 1

Default cache usage pattern. Use with setCacheMode(int).

Constant Value: -1 (0xffffffff)

public static final int LOAD_NORMAL

Since: API Level 1

Normal cache usage pattern. Use with setCacheMode(int).

Constant Value: 0 (0x00000000)

public static final int LOAD_NO_CACHE

Since: API Level 1

Don't use the cache, load from network. Use with setCacheMode(int).

Constant Value: 2 (0x00000002)

Public Methods

public boolean enableSmoothTransition ()

Since: API Level 11

Gets whether the WebView enables smooth transition while panning or zooming.

public boolean getAllowContentAccess ()

Since: API Level 11

Gets whether this WebView supports content URL access.

public boolean getAllowFileAccess ()

Since: API Level 3

Gets whether this WebView supports file access.

public abstract boolean getAllowFileAccessFromFileURLs ()

Since: API Level 16

Gets whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs.

Returns
  • whether JavaScript running in the context of a file scheme URL can access content from other file scheme URLs

public abstract boolean getAllowUniversalAccessFromFileURLs ()

Since: API Level 16

Gets whether JavaScript running in the context of a file scheme URL can access content from any origin. This includes access to content from other file scheme URLs.

Returns
  • whether JavaScript running in the context of a file scheme URL can access content from any origin

public synchronized boolean getBlockNetworkImage ()

Since: API Level 1

Gets whether the WebView does not load image resources from the network.

Returns
  • true if the WebView does not load image resources from the network

public synchronized boolean getBlockNetworkLoads ()

Since: API Level 8

Gets whether the WebView does not load any resources from the network.

Returns
  • true if the WebView does not load any resources from the network

public boolean getBuiltInZoomControls ()

Since: API Level 3

Gets whether the zoom mechanisms built into WebView are being used.

Returns
  • true if the zoom mechanisms built into WebView are being used

public int getCacheMode ()

Since: API Level 1

Gets the current setting for overriding the cache mode. For a full description, see the setCacheMode(int) function.

public synchronized String getCursiveFontFamily ()

Since: API Level 1

Gets the cursive font family name.

Returns
  • the cursive font family name as a string

public synchronized boolean getDatabaseEnabled ()

Since: API Level 5

Gets whether the database storage API is enabled.

Returns
  • true if the database storage API is enabled

public synchronized String getDatabasePath ()

Since: API Level 5

Gets the path to where database storage API databases are saved for the current WebView.

Returns
  • the String path to the database storage API databases

public synchronized int getDefaultFixedFontSize ()

Since: API Level 1

Gets the default fixed font size.

Returns
  • a non-negative integer between 1 and 72

public synchronized int getDefaultFontSize ()

Since: API Level 1

Gets the default font size.

Returns
  • a non-negative integer between 1 and 72

public synchronized String getDefaultTextEncodingName ()

Since: API Level 1

Gets the default text encoding name.

Returns
  • the default text encoding name as a string

public WebSettings.ZoomDensity getDefaultZoom ()

Since: API Level 7

Gets the default zoom density of the page. This should be called from UI thread.

Returns
  • a ZoomDensity value

public boolean getDisplayZoomControls ()

Since: API Level 11

Gets whether the WebView displays on-screen zoom controls when using the built-in zoom mechanisms.

Returns
  • true if the WebView displays on-screen zoom controls when using the built-in zoom mechanisms

public synchronized boolean getDomStorageEnabled ()

Since: API Level 7

Gets whether the DOM Storage APIs are enabled.

Returns
  • true if the DOM Storage APIs are enabled

public synchronized String getFantasyFontFamily ()

Since: API Level 1

Gets the fantasy font family name.

Returns
  • the fantasy font family name as a string

public synchronized String getFixedFontFamily ()

Since: API Level 1

Gets the fixed font family name.

Returns
  • the fixed font family name as a string

public synchronized boolean getJavaScriptCanOpenWindowsAutomatically ()

Since: API Level 1

Gets whether JavaScript can open windows automatically.

Returns
  • true if JavaScript can open windows automatically during window.open()

public synchronized boolean getJavaScriptEnabled ()

Since: API Level 1

Gets whether JavaScript is enabled.

Returns
  • true if JavaScript is enabled

public synchronized WebSettings.LayoutAlgorithm getLayoutAlgorithm ()

Since: API Level 1

Gets the current layout algorithm.

Returns
  • a LayoutAlgorithm enum value describing the layout algorithm being used

public boolean getLightTouchEnabled ()

Since: API Level 1

Gets whether light touches are enabled.

public boolean getLoadWithOverviewMode ()

Since: API Level 7

Gets whether this WebView loads pages with overview mode.

public synchronized boolean getLoadsImagesAutomatically ()

Since: API Level 1

Gets whether the WebView loads image resources. This includes images embedded using the data URI scheme.

Returns
  • true if the WebView loads image resources

public synchronized int getMinimumFontSize ()

Since: API Level 1

Gets the minimum font size.

Returns
  • a non-negative integer between 1 and 72

public synchronized int getMinimumLogicalFontSize ()

Since: API Level 1

Gets the minimum logical font size.

Returns
  • a non-negative integer between 1 and 72

public boolean getNavDump ()

Since: API Level 1

This method is deprecated.
This method is now obsolete.

Gets whether dumping the navigation cache is enabled.

public synchronized WebSettings.PluginState getPluginState ()

Since: API Level 8

Gets the current plugin state.

Returns
  • a value corresponding to the enum PluginState

public synchronized boolean getPluginsEnabled ()

Since: API Level 1

This method is deprecated.
This method has been replaced by getPluginState()

Gets whether plugins are enabled.

Returns
  • true if plugins are enabled

public synchronized String getPluginsPath ()

Since: API Level 1

This method is deprecated.
This method is no longer used as plugins are loaded from their own APK via the system's package manager.

Gets the directory that contains the plugin libraries. This method is obsolete since each plugin is now loaded from its own package.

Returns
  • an empty string

public synchronized String getSansSerifFontFamily ()

Since: API Level 1

Gets the sans-serif font family name.

Returns
  • the sans-serif font family name as a string

public boolean getSaveFormData ()

Since: API Level 1

Gets whether the WebView is saving form data and displaying prior entries/autofill++. Always false in private browsing mode.

public boolean getSavePassword ()

Since: API Level 1

Gets whether the WebView is saving password.

public synchronized String getSerifFontFamily ()

Since: API Level 1

Gets the serif font family name. The default is "serif".

Returns
  • the serif font family name as a string

public synchronized String getStandardFontFamily ()

Since: API Level 1

Gets the standard font family name.

Returns
  • the standard font family name as a string

public synchronized WebSettings.TextSize getTextSize ()

Since: API Level 1

This method is deprecated.
Use getTextZoom() instead.

Gets the text size of the page. If the text size was previously specified in percent using setTextZoom(int), this will return the closest matching WebSettings.TextSize.

Returns
  • a TextSize enum value describing the text size

public synchronized int getTextZoom ()

Since: API Level 14

Gets the text zoom of the page in percent.

Returns
  • a percent value describing the text zoom

public synchronized boolean getUseDoubleTree ()

Since: API Level 1

This method is deprecated.
This setting now has no effect.

Controlled a rendering optimization that is no longer present. Setting it now has no effect.

public boolean getUseWebViewBackgroundForOverscrollBackground ()

Since: API Level 9

This method is deprecated.
This method is now obsolete.

Gets whether this WebView uses WebView's background instead of internal pattern for over scroll background.

public synchronized boolean getUseWideViewPort ()

Since: API Level 1

Gets whether the WebView is using a wide viewport.

Returns
  • true if the WebView is using a wide viewport

public synchronized int getUserAgent ()

Since: API Level 1

This method is deprecated.
Please use getUserAgentString instead.

Gets the user-agent as an int.

Returns
  • 0 if the WebView is using an Android user-agent string, 1 if the WebView is using a desktop user-agent string, -1 if the WebView is using user defined user-agent string

public synchronized String getUserAgentString ()

Since: API Level 3

Gets the WebView's user-agent string.

public void setAllowContentAccess (boolean allow)

Since: API Level 11

Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default is enabled.

public void setAllowFileAccess (boolean allow)

Since: API Level 3

Enables or disables file access within WebView. File access is enabled by default. Note that this enables or disables file system access only. Assets and resources are still accessible using file:///android_asset and file:///android_res.

public abstract void setAllowFileAccessFromFileURLs (boolean flag)

Since: API Level 16

Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. To enable the most restrictive, and therefore secure policy, this setting should be disabled. Note that the value of this setting is ignored if the value of getAllowUniversalAccessFromFileURLs() is true.

The default value is true for API level ICE_CREAM_SANDWICH_MR1 and below, and false for API level JELLY_BEAN and above.

Parameters
flag whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs

public abstract void setAllowUniversalAccessFromFileURLs (boolean flag)

Since: API Level 16

Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. This includes access to content from other file scheme URLs. See setAllowFileAccessFromFileURLs(boolean). To enable the most restrictive, and therefore secure policy, this setting should be disabled.

The default value is true for API level ICE_CREAM_SANDWICH_MR1 and below, and false for API level JELLY_BEAN and above.

Parameters
flag whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin

public synchronized void setAppCacheEnabled (boolean flag)

Since: API Level 7

Tells the WebView to enable Application Caches API.

Parameters
flag true if the WebView should enable Application Caches

public synchronized void setAppCacheMaxSize (long appCacheMaxSize)

Since: API Level 7

Sets the maximum size for the Application Caches content.

Parameters
appCacheMaxSize the maximum size in bytes

public synchronized void setAppCachePath (String appCachePath)

Since: API Level 7

Sets a custom path to the Application Caches files. The client must ensure it exists before this call.

Parameters
appCachePath a String path to the directory containing Application Caches files. The appCache path can be the empty string but should not be null. Passing null for this parameter will result in a no-op.

public synchronized void setBlockNetworkImage (boolean flag)

Since: API Level 1

Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes). Note that this method has no effect unless getLoadsImagesAutomatically() returns true. Also note that disabling all network loads using setBlockNetworkLoads(boolean) will also prevent network images from loading, even if this flag is set to false. When the value of this setting is changed from true to false, network images resources referenced by content currently displayed by the WebView are fetched automatically. The default is false.

Parameters
flag whether the WebView should not load image resources from the network

public synchronized void setBlockNetworkLoads (boolean flag)

Since: API Level 8

Sets whether the WebView should not load resources from the network. Use setBlockNetworkImage(boolean) to only avoid loading image resources. Note that if the value of this setting is changed from true to false, network resources referenced by content currently displayed by the WebView are not fetched until reload() is called. If the application does not have the INTERNET permission, attempts to set a value of false will cause a SecurityException to be thrown. The default value is false if the application has the INTERNET permission, otherwise it is true.

Parameters
flag whether the WebView should not load any resources from the network
See Also

public void setBuiltInZoomControls (boolean enabled)

Since: API Level 3

Sets whether the WebView should use its built-in zoom mechanisms. The built-in zoom mechanisms comprise on-screen zoom controls, which are displayed over the WebView's content, and the use of a pinch gesture to control zooming. Whether or not these on-screen controls are displayed can be set with setDisplayZoomControls(boolean). The default is false.

The built-in mechanisms are the only currently supported zoom mechanisms, so it is recommended that this setting is always enabled.

Parameters
enabled whether the WebView should use its built-in zoom mechanisms

public void setCacheMode (int mode)

Since: API Level 1

Overrides the way the cache is used. The way the cache is used is based on the navigation option. For a normal page load, the cache is checked and content is re-validated as needed. When navigating back, content is not revalidated, instead the content is just pulled from the cache. This function allows the client to override this behavior.

Parameters
mode one of the LOAD_ values

public synchronized void setCursiveFontFamily (String font)

Since: API Level 1

Sets the cursive font family name. The default is "cursive".

Parameters
font a font family name

public synchronized void setDatabaseEnabled (boolean flag)

Since: API Level 5

Sets whether the database storage API is enabled.

Parameters
flag true if the WebView should use the database storage API

public synchronized void setDatabasePath (String databasePath)

Since: API Level 5

Sets the path to where database storage API databases should be saved. Note that the WebCore Database Tracker only allows the path to be set once.

Parameters
databasePath a String path to the directory where databases should be saved. May be the empty string but should never be null.

public synchronized void setDefaultFixedFontSize (int size)

Since: API Level 1

Sets the default fixed font size. The default is 16.

Parameters
size a non-negative integer between 1 and 72. Any number outside the specified range will be pinned.

public synchronized void setDefaultFontSize (int size)

Since: API Level 1

Sets the default font size. The default is 16.

Parameters
size a non-negative integer between 1 and 72. Any number outside the specified range will be pinned.

public synchronized void setDefaultTextEncodingName (String encoding)

Since: API Level 1

Sets the default text encoding name to use when decoding html pages. The default is "Latin-1".

Parameters
encoding the text encoding name

public void setDefaultZoom (WebSettings.ZoomDensity zoom)

Since: API Level 7

Sets the default zoom density of the page. This should be called from UI thread.

Parameters
zoom a ZoomDensity value

public void setDisplayZoomControls (boolean enabled)

Since: API Level 11

Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. See setBuiltInZoomControls(boolean). The default is true.

Parameters
enabled whether the WebView should display on-screen zoom controls

public synchronized void setDomStorageEnabled (boolean flag)

Since: API Level 7

Sets whether the DOM storage API is enabled.

Parameters
flag true if the WebView should use the DOM storage API

public void setEnableSmoothTransition (boolean enable)

Since: API Level 11

Sets whether the WebView will enable smooth transition while panning or zooming or while the window hosting the WebView does not have focus. If it is true, WebView will choose a solution to maximize the performance. e.g. the WebView's content may not be updated during the transition. If it is false, WebView will keep its fidelity. The default value is false.

public synchronized void setFantasyFontFamily (String font)

Since: API Level 1

Sets the fantasy font family name. The default is "fantasy".

Parameters
font a font family name

public synchronized void setFixedFontFamily (String font)

Since: API Level 1

Sets the fixed font family name. The default is "monospace".

Parameters
font a font family name

public synchronized void setGeolocationDatabasePath (String databasePath)

Since: API Level 5

Sets the path where the Geolocation permissions database should be saved.

Parameters
databasePath a String path to the directory where the Geolocation permissions database should be saved. May be the empty string but should never be null.

public synchronized void setGeolocationEnabled (boolean flag)

Since: API Level 5

Sets whether Geolocation is enabled.

Parameters
flag whether Geolocation should be enabled

public synchronized void setJavaScriptCanOpenWindowsAutomatically (boolean flag)

Since: API Level 1

Tells JavaScript to open windows automatically. This applies to the JavaScript function window.open(). The default is false.

Parameters
flag true if JavaScript can open windows automatically

public synchronized void setJavaScriptEnabled (boolean flag)

Since: API Level 1

Tells the WebView to enable JavaScript execution. The default is false.

Parameters
flag true if the WebView should execute JavaScript

public synchronized void setLayoutAlgorithm (WebSettings.LayoutAlgorithm l)

Since: API Level 1

Sets the underlying layout algorithm. This will cause a relayout of the WebView. The default is NARROW_COLUMNS.

Parameters
l a LayoutAlgorithm enum specifying the algorithm to use

public void setLightTouchEnabled (boolean enabled)

Since: API Level 1

Enables using light touches to make a selection and activate mouseovers.

public void setLoadWithOverviewMode (boolean overview)

Since: API Level 7

Sets whether the WebView loads a page with overview mode.

public synchronized void setLoadsImagesAutomatically (boolean flag)

Since: API Level 1

Sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme. Use setBlockNetworkImage(boolean) to control loading only of images specified using network URI schemes. Note that if the value of this setting is changed from false to true, all images resources referenced by content currently displayed by the WebView are loaded automatically. The default is true.

Parameters
flag whether the WebView should load image resources

public synchronized void setMinimumFontSize (int size)

Since: API Level 1

Sets the minimum font size. The default is 8.

Parameters
size a non-negative integer between 1 and 72. Any number outside the specified range will be pinned.

public synchronized void setMinimumLogicalFontSize (int size)

Since: API Level 1

Sets the minimum logical font size. The default is 8.

Parameters
size a non-negative integer between 1 and 72. Any number outside the specified range will be pinned.

public void setNavDump (boolean enabled)

Since: API Level 1

This method is deprecated.
This method is now obsolete.

Enables dumping the pages navigation cache to a text file.

public void setNeedInitialFocus (boolean flag)

Since: API Level 1

Tells the WebView whether it needs to set a node to have focus when requestFocus(int, android.graphics.Rect) is called.

Parameters
flag whether the WebView needs to set a node

public synchronized void setPluginState (WebSettings.PluginState state)

Since: API Level 8

Tells the WebView to enable, disable, or have plugins on demand. On demand mode means that if a plugin exists that can handle the embedded content, a placeholder icon will be shown instead of the plugin. When the placeholder is clicked, the plugin will be enabled.

Parameters
state a PluginState value

public synchronized void setPluginsEnabled (boolean flag)

Since: API Level 1

This method is deprecated.
This method has been deprecated in favor of setPluginState(WebSettings.PluginState)

Tells the WebView to enable plugins.

Parameters
flag true if the WebView should load plugins

public synchronized void setPluginsPath (String pluginsPath)

Since: API Level 1

This method is deprecated.
This method is no longer used as plugins are loaded from their own APK via the system's package manager.

Sets a custom path to plugins used by the WebView. This method is obsolete since each plugin is now loaded from its own package.

Parameters
pluginsPath a String path to the directory containing plugins

public synchronized void setRenderPriority (WebSettings.RenderPriority priority)

Since: API Level 1

Sets the priority of the Render thread. Unlike the other settings, this one only needs to be called once per process. The default is NORMAL.

Parameters
priority a RenderPriority

public synchronized void setSansSerifFontFamily (String font)

Since: API Level 1

Sets the sans-serif font family name.

Parameters
font a font family name

public void setSaveFormData (boolean save)

Since: API Level 1

Sets whether the WebView is saving form data.

public void setSavePassword (boolean save)

Since: API Level 1

Stores whether the WebView is saving password.

public synchronized void setSerifFontFamily (String font)

Since: API Level 1

Sets the serif font family name. The default is "sans-serif".

Parameters
font a font family name

public synchronized void setStandardFontFamily (String font)

Since: API Level 1

Sets the standard font family name. The default is "sans-serif".

Parameters
font a font family name

public synchronized void setSupportMultipleWindows (boolean support)

Since: API Level 1

Tells the WebView whether it supports multiple windows. TRUE means that onCreateWindow(WebView, boolean, boolean, Message) is implemented by the host application.

public void setSupportZoom (boolean support)

Since: API Level 1

Sets whether the WebView should support zooming using its on-screen zoom controls and gestures. The particular zoom mechanisms that should be used can be set with setBuiltInZoomControls(boolean). This setting does not affect zooming performed using the zoomIn() and zoomOut() methods. The default is true.

Parameters
support whether the WebView should support zoom

public synchronized void setTextSize (WebSettings.TextSize t)

Since: API Level 1

This method is deprecated.
Use setTextZoom(int) instead.

Sets the text size of the page.

Parameters
t the TextSize value for increasing or decreasing the text

public synchronized void setTextZoom (int textZoom)

Since: API Level 14

Sets the text zoom of the page in percent. Default is 100.

Parameters
textZoom the percent value for increasing or decreasing the text

public synchronized void setUseDoubleTree (boolean use)

Since: API Level 1

This method is deprecated.
This setting now has no effect.

Controlled a rendering optimization that is no longer present. Setting it now has no effect.

public void setUseWebViewBackgroundForOverscrollBackground (boolean view)

Since: API Level 9

This method is deprecated.
This method is now obsolete.

Sets whether the WebView uses its background for over scroll background. If true, it will use the WebView's background. If false, it will use an internal pattern. Default is true.

public synchronized void setUseWideViewPort (boolean use)

Since: API Level 1

Tells the WebView to use the wide viewport.

public synchronized void setUserAgent (int ua)

Since: API Level 1

This method is deprecated.
Please use setUserAgentString instead.

Tells the WebView about user-agent string.

Parameters
ua 0 if the WebView should use an Android user-agent string, 1 if the WebView should use a desktop user-agent string

public synchronized void setUserAgentString (String ua)

Since: API Level 3

Sets the WebView's user-agent string. If the string "ua" is null or empty, it will use the system default user-agent string.

public synchronized boolean supportMultipleWindows ()

Since: API Level 1

Gets whether the WebView is supporting multiple windows.

Returns

public boolean supportZoom ()

Since: API Level 1

Gets whether the WebView supports zoom.

Returns
  • true if the WebView supports zoom