java.lang.Object | |
↳ | android.webkit.WebSettings |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
WebSettings.LayoutAlgorithm | This enum is deprecated. This enum is now obsolete. | ||||||||||
WebSettings.PluginState | The plugin state effects how plugins are treated on a page. | ||||||||||
WebSettings.RenderPriority | |||||||||||
WebSettings.TextSize |
This enum is deprecated.
Use setTextZoom(int) and getTextZoom() instead.
|
||||||||||
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) If it is not in the cache, load from network. | |||||||||
int | LOAD_CACHE_ONLY | Don't use the network, load from cache only. | |||||||||
int | LOAD_DEFAULT | Default cache usage pattern Use with setCacheMode(int) . |
|||||||||
int | LOAD_NORMAL | Normal cache usage pattern Use with setCacheMode(int) . |
|||||||||
int | LOAD_NO_CACHE | Don't use the cache, load from network
Use with setCacheMode(int) . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if the WebView enables smooth transition while panning or
zooming.
| |||||||||||
Returns true if this WebView supports content url access.
| |||||||||||
Returns true if this WebView supports file access.
| |||||||||||
Return true if the WebView will block network images.
| |||||||||||
Return true if the WebView will block all network loads.
| |||||||||||
Returns true if the zoom mechanism built into WebView is being used.
| |||||||||||
Return the current setting for overriding the cache mode.
| |||||||||||
Get the cursive font family name.
| |||||||||||
Returns true if database storage API is enabled.
| |||||||||||
Return the path to where database storage API databases are saved for
the current WebView.
| |||||||||||
Get the default fixed font size.
| |||||||||||
Get the default font size.
| |||||||||||
Get the default text encoding name.
| |||||||||||
Get the default zoom density of the page.
| |||||||||||
Returns true if the on screen zoom buttons are being used.
| |||||||||||
Returns true if the DOM Storage API's are enabled.
| |||||||||||
Get the fantasy font family name.
| |||||||||||
Get the fixed font family name.
| |||||||||||
Return true if javascript can open windows automatically.
| |||||||||||
Return true if javascript is enabled.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
Returns true if light touches are enabled.
| |||||||||||
Returns true if this WebView loads page with overview mode
| |||||||||||
Return true if the WebView will load image resources automatically.
| |||||||||||
Get the minimum font size.
| |||||||||||
Get the minimum logical font size.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
Return the current plugin state.
| |||||||||||
This method is deprecated.
This method has been replaced by
getPluginState()
| |||||||||||
This method is deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
| |||||||||||
Get the sans-serif font family name.
| |||||||||||
Return whether the WebView is saving form data and displaying prior
entries/autofill++.
| |||||||||||
Return whether the WebView is saving password.
| |||||||||||
Get the serif font family name.
| |||||||||||
Get the standard font family name.
| |||||||||||
This method is deprecated.
Use
getTextZoom() instead
| |||||||||||
Get the text zoom of the page in percent.
| |||||||||||
This method is deprecated.
This setting controlled a rendering optimization
that is no longer present. Setting it now has no effect.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
This method is deprecated.
Please use getUserAgentString instead.
| |||||||||||
Return the WebView's user-agent string.
| |||||||||||
Enable or disable content url access within WebView.
| |||||||||||
Enable or disable file access within WebView.
| |||||||||||
Tell the WebView to enable Application Caches API.
| |||||||||||
Set the maximum size for the Application Caches content.
| |||||||||||
Set a custom path to the Application Caches files.
| |||||||||||
Tell the WebView to block network images.
| |||||||||||
Tell the WebView to block all network load requests.
| |||||||||||
Sets whether the zoom mechanism built into WebView is used.
| |||||||||||
Override the way the cache is used.
| |||||||||||
Set the cursive font family name.
| |||||||||||
Set whether the database storage API is enabled.
| |||||||||||
Set the path to where database storage API databases should be saved.
| |||||||||||
Set the default fixed font size.
| |||||||||||
Set the default font size.
| |||||||||||
Set the default text encoding name to use when decoding html pages.
| |||||||||||
Set the default zoom density of the page.
| |||||||||||
Sets whether the on screen zoom buttons are used.
| |||||||||||
Set whether the DOM storage API is enabled.
| |||||||||||
Set whether the WebView will enable smooth transition while panning or
zooming or while the window hosting the WebView does not have focus.
| |||||||||||
Set the fantasy font family name.
| |||||||||||
Set the fixed font family name.
| |||||||||||
Set the path where the Geolocation permissions database should be saved.
| |||||||||||
Sets whether Geolocation is enabled.
| |||||||||||
Tell javascript to open windows automatically.
| |||||||||||
Tell the WebView to enable javascript execution.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
Enables using light touches to make a selection and activate mouseovers.
| |||||||||||
Set whether the WebView loads a page with overview mode.
| |||||||||||
Tell the WebView to load image resources automatically.
| |||||||||||
Set the minimum font size.
| |||||||||||
Set the minimum logical font size.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
Tell the WebView whether it needs to set a node to have focus when
requestFocus(int, android.graphics.Rect) is called. | |||||||||||
Tell the WebView to enable, disable, or have plugins on demand.
| |||||||||||
This method is deprecated.
This method has been deprecated in favor of
setPluginState(WebSettings.PluginState)
| |||||||||||
This method is deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
| |||||||||||
Set the priority of the Render thread.
| |||||||||||
Set the sans-serif font family name.
| |||||||||||
Store whether the WebView is saving form data.
| |||||||||||
Store whether the WebView is saving password.
| |||||||||||
Set the serif font family name.
| |||||||||||
Set the standard font family name.
| |||||||||||
Tell the WebView whether it supports multiple windows.
| |||||||||||
Set whether the WebView supports zoom
| |||||||||||
This method is deprecated.
Use
setTextZoom(int) instead
| |||||||||||
Set the text zoom of the page in percent.
| |||||||||||
This method is deprecated.
This setting controlled a rendering optimization
that is no longer present. Setting it now has no effect.
| |||||||||||
This method is deprecated.
This method is now obsolete.
| |||||||||||
Tell the WebView to use the wide viewport
| |||||||||||
This method is deprecated.
Please use setUserAgentString instead.
| |||||||||||
Set the WebView's user-agent string.
| |||||||||||
Returns whether the WebView supports zoom
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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)
.
Don't use the network, load from cache only.
Use with setCacheMode(int)
.
Default cache usage pattern Use with setCacheMode(int)
.
Normal cache usage pattern Use with setCacheMode(int)
.
Don't use the cache, load from network
Use with setCacheMode(int)
.
Returns true if the WebView enables smooth transition while panning or zooming.
Returns true if this WebView supports content url access.
Returns true if this WebView supports file access.
Return true if the WebView will block network images. The default is false.
Return true if the WebView will block all network loads. The default is false.
Returns true if the zoom mechanism built into WebView is being used.
Return the current setting for overriding the cache mode. For a full
description, see the setCacheMode(int)
function.
Get the cursive font family name. The default is "cursive".
Returns true if database storage API is enabled.
Return the path to where database storage API databases are saved for the current WebView.
Get the default fixed font size. The default is 16.
Get the default font size. The default is 16.
Get the default text encoding name. The default is "Latin-1".
Get the default zoom density of the page. This should be called from UI thread.
Returns true if the on screen zoom buttons are being used.
Returns true if the DOM Storage API's are enabled.
Get the fantasy font family name. The default is "fantasy".
Get the fixed font family name. The default is "monospace".
Return true if javascript can open windows automatically. The default is false.
Return true if javascript is enabled. Note: The default is false.
This method is deprecated.
This method is now obsolete.
Return the current layout algorithm. The default is NARROW_COLUMNS.
Returns true if light touches are enabled.
Returns true if this WebView loads page with overview mode
Return true if the WebView will load image resources automatically. The default is true.
Get the minimum font size. The default is 8.
Get the minimum logical font size. The default is 8.
This method is deprecated.
This method is now obsolete.
Returns true if dumping the navigation cache is enabled.
Return the current plugin state.
This method is deprecated.
This method has been replaced by getPluginState()
Return true if plugins are enabled.
This method is deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
Returns the directory that contains the plugin libraries. This method is obsolete since each plugin is now loaded from its own package.
Get the sans-serif font family name.
Return whether the WebView is saving form data and displaying prior entries/autofill++. Always false in private browsing mode.
Get the serif font family name. The default is "serif".
Get the standard font family name. The default is "sans-serif".
This method is deprecated.
Use getTextZoom()
instead
Get 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
.
Get the text zoom of the page in percent.
This method is deprecated.
This setting controlled a rendering optimization
that is no longer present. Setting it now has no effect.
This method is deprecated.
This method is now obsolete.
Returns true if this WebView uses WebView's background instead of internal pattern for over scroll background.
This method is deprecated.
Please use getUserAgentString instead.
Return user-agent as int
Return the WebView's user-agent string.
Enable or disable 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.
Enable or disable 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.
Tell the WebView to enable Application Caches API.
flag | True if the WebView should enable Application Caches. |
---|
Set the maximum size for the Application Caches content.
appCacheMaxSize | the maximum size in bytes. |
---|
Set a custom path to the Application Caches files. The client must ensure it exists before this call.
appCachePath | 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. |
---|
Tell the WebView to block network images. This is only checked when
getLoadsImagesAutomatically()
is true. If you set the value to
false, images will automatically be loaded. Use this api to reduce
bandwidth only. Use setBlockNetworkLoads(boolean)
if possible.
flag | True if the WebView should block network images. |
---|
Tell the WebView to block all network load requests. If you set the
value to false, you must call reload()
to
fetch remote resources. This flag supercedes the value passed to
setBlockNetworkImage(boolean)
.
flag | True if the WebView should block all network loads. |
---|
Sets whether the zoom mechanism built into WebView is used.
Override 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.
mode | One of the LOAD_ values. |
---|
Set the cursive font family name.
font | A font family name. |
---|
Set whether the database storage API is enabled.
flag | boolean True if the WebView should use the database storage API. |
---|
Set the path to where database storage API databases should be saved. Nota that the WebCore Database Tracker only allows the path to be set once. This will update WebCore when the Sync runs in the C++ side.
databasePath | String path to the directory where databases should be saved. May be the empty string but should never be null. |
---|
Set the default fixed font size.
size | A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. |
---|
Set the default font size.
size | A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. |
---|
Set the default text encoding name to use when decoding html pages.
encoding | The text encoding name. |
---|
Set the default zoom density of the page. This should be called from UI thread.
zoom | A ZoomDensity value |
---|
Sets whether the on screen zoom buttons are used. A combination of built in zoom controls enabled and on screen zoom controls disabled allows for pinch to zoom to work without the on screen controls
Set whether the DOM storage API is enabled.
flag | boolean True if the WebView should use the DOM storage API. |
---|
Set 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.
Set the fantasy font family name.
font | A font family name. |
---|
Set the fixed font family name.
font | A font family name. |
---|
Set the path where the Geolocation permissions database should be saved. This will update WebCore when the Sync runs in the C++ side.
databasePath | String path to the directory where the Geolocation permissions database should be saved. May be the empty string but should never be null. |
---|
Sets whether Geolocation is enabled.
flag | Whether Geolocation should be enabled. |
---|
Tell javascript to open windows automatically. This applies to the javascript function window.open().
flag | True if javascript can open windows automatically. |
---|
Tell the WebView to enable javascript execution.
flag | True if the WebView should execute javascript. |
---|
This method is deprecated.
This method is now obsolete.
Set the underlying layout algorithm. This will cause a relayout of the WebView.
l | A LayoutAlgorithm enum specifying the algorithm to use. |
---|
Enables using light touches to make a selection and activate mouseovers.
Set whether the WebView loads a page with overview mode.
Tell the WebView to load image resources automatically.
flag | True if the WebView should load images automatically. |
---|
Set the minimum font size.
size | A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. |
---|
Set the minimum logical font size.
size | A non-negative integer between 1 and 72. Any number outside the specified range will be pinned. |
---|
This method is deprecated.
This method is now obsolete.
Enables dumping the pages navigation cache to a text file.
Tell the WebView whether it needs to set a node to have focus when
requestFocus(int, android.graphics.Rect)
is called.
Tell 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.
state | One of the PluginState values. |
---|
This method is deprecated.
This method has been deprecated in favor of
setPluginState(WebSettings.PluginState)
Tell the WebView to enable plugins.
flag | True if the WebView should load plugins. |
---|
This method is deprecated.
This method is no longer used as plugins are loaded from
their own APK via the system's package manager.
Set a custom path to plugins used by the WebView. This method is obsolete since each plugin is now loaded from its own package.
pluginsPath | String path to the directory containing plugins. |
---|
Set the priority of the Render thread. Unlike the other settings, this one only needs to be called once per process. The default is NORMAL.
priority | RenderPriority, can be normal, high or low. |
---|
Set the sans-serif font family name.
font | A font family name. |
---|
Store whether the WebView is saving form data.
Store whether the WebView is saving password.
Set the serif font family name. The default is "sans-serif".
font | A font family name. |
---|
Set the standard font family name.
font | A font family name. |
---|
Tell the WebView whether it supports multiple windows. TRUE means
that onCreateWindow(WebView, boolean, boolean, Message)
is implemented by the host application.
Set whether the WebView supports zoom
This method is deprecated.
Use setTextZoom(int)
instead
Set the text size of the page.
t | A TextSize value for increasing or decreasing the text. |
---|
Set the text zoom of the page in percent. Default is 100.
textZoom | A percent value for increasing or decreasing the text. |
---|
This method is deprecated.
This setting controlled a rendering optimization
that is no longer present. Setting it now has no effect.
This method is deprecated.
This method is now obsolete.
Set 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.
Tell the WebView to use the wide viewport
This method is deprecated.
Please use setUserAgentString instead.
Tell the WebView about user-agent string.
ua | 0 if the WebView should use an Android user-agent string, 1 if the WebView should use a desktop user-agent string. |
---|
Set the WebView's user-agent string. If the string "ua" is null or empty, it will use the system default user-agent string.
onCreateWindow(WebView, boolean, boolean, Message)
is implemented by the host application.