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
Summary
Constants
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
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.
Use with
setCacheMode(int).
Constant Value:
1
(0x00000001)
public
static
final
int
LOAD_CACHE_ONLY
Don't use the network, load from cache only.
Use with
setCacheMode(int).
Constant Value:
3
(0x00000003)
public
static
final
int
LOAD_DEFAULT
Default cache usage pattern Use with
setCacheMode(int).
Constant Value:
-1
(0xffffffff)
public
static
final
int
LOAD_NORMAL
Normal cache usage pattern Use with
setCacheMode(int).
Constant Value:
0
(0x00000000)
public
static
final
int
LOAD_NO_CACHE
Don't use the cache, load from network
Use with
setCacheMode(int).
Constant Value:
2
(0x00000002)
Public Methods
public
synchronized
boolean
getBlockNetworkImage()
Return true if the WebView will block network image.
Returns
- True if the WebView blocks network image.
public
int
getCacheMode()
Return the current setting for overriding the cache mode. For a full
description, see the
setCacheMode(int) function.
public
synchronized
String
getCursiveFontFamily()
Get the cursive font family name.
Returns
- The cursive font family name as a string.
public
synchronized
int
getDefaultFixedFontSize()
Get the default fixed font size.
Returns
- A non-negative integer between 1 and 72.
public
synchronized
int
getDefaultFontSize()
Get the default font size.
Returns
- A non-negative integer between 1 and 72.
public
synchronized
String
getDefaultTextEncodingName()
Get the default text encoding name.
Returns
- The default text encoding name as a string.
public
synchronized
String
getFantasyFontFamily()
Get the fantasy font family name.
Returns
- The fantasy font family name as a string.
public
synchronized
String
getFixedFontFamily()
Get the fixed font family name.
Returns
- The fixed font family name as a string.
public
synchronized
boolean
getJavaScriptCanOpenWindowsAutomatically()
Return true if javascript can open windows automatically.
Returns
- True if javascript can open windows automatically during
window.open().
public
synchronized
boolean
getJavaScriptEnabled()
Return true if javascript is enabled.
Returns
- True if javascript is enabled.
Return the current layout algorithm.
Returns
- LayoutAlgorithm enum value describing the layout algorithm
being used.
public
boolean
getLightTouchEnabled()
Returns true if light touches are enabled.
public
synchronized
boolean
getLoadsImagesAutomatically()
Return true if the WebView will load image resources automatically.
Returns
- True if the WebView loads images automatically.
public
synchronized
int
getMinimumFontSize()
Get the minimum font size.
Returns
- A non-negative integer between 1 and 72.
public
synchronized
int
getMinimumLogicalFontSize()
Get the minimum logical font size.
Returns
- A non-negative integer between 1 and 72.
public
boolean
getNavDump()
Returns true if dumping the navigation cache is enabled.
public
synchronized
boolean
getPluginsEnabled()
Return true if plugins are enabled.
Returns
- True if plugins are enabled.
public
synchronized
String
getPluginsPath()
Return the current path used for plugins in the WebView.
Returns
- The string path to the WebView plugins.
public
synchronized
String
getSansSerifFontFamily()
Get the sans-serif font family name.
Returns
- The sans-serif font family name as a string.
public
boolean
getSaveFormData()
Return whether the WebView is saving form data.
public
boolean
getSavePassword()
Return whether the WebView is saving password.
public
synchronized
String
getSerifFontFamily()
Get the serif font family name.
Returns
- The serif font family name as a string.
public
synchronized
String
getStandardFontFamily()
Get the standard font family name.
Returns
- The standard font family name as a string.
Get the text size of the page.
Returns
- A TextSize enum value describing the text size.
public
synchronized
boolean
getUseDoubleTree()
Return true if the WebView is using the double tree rendering algorithm.
Returns
- True if the WebView is using the double tree rendering
algorithm.
public
synchronized
boolean
getUseWideViewPort()
Returns
- True if the WebView is using a wide viewport
public
synchronized
int
getUserAgent()
Return user-agent as int
Returns
- int 0 if the WebView is using an Android user-agent string.
1 if the WebView is using a desktop user-agent string.
2 if the WebView is using an iPhone user-agent string.
public
synchronized
void
setBlockNetworkImage(boolean flag)
Tell the WebView to block network image. This is only checked when
getLoadsImagesAutomatically() is true.
Parameters
flag
| True if the WebView should block network image
|
public
void
setCacheMode(int mode)
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.
Parameters
mode
| One of the LOAD_ values.
|
public
synchronized
void
setCursiveFontFamily(String font)
Set the cursive font family name.
public
synchronized
void
setDefaultFixedFontSize(int size)
Set the default fixed font size.
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)
Set the default font size.
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)
Set the default text encoding name to use when decoding html pages.
Parameters
encoding
| The text encoding name.
|
public
synchronized
void
setFantasyFontFamily(String font)
Set the fantasy font family name.
public
synchronized
void
setFixedFontFamily(String font)
Set the fixed font family name.
public
synchronized
void
setJavaScriptCanOpenWindowsAutomatically(boolean flag)
Tell javascript to open windows automatically. This applies to the
javascript function window.open().
Parameters
flag
| True if javascript can open windows automatically.
|
public
synchronized
void
setJavaScriptEnabled(boolean flag)
Tell the WebView to enable javascript execution.
Parameters
flag
| True if the WebView should execute javascript.
|
Set the underlying layout algorithm. This will cause a relayout of the
WebView.
Parameters
l
| A LayoutAlgorithm enum specifying the algorithm to use. |
public
void
setLightTouchEnabled(boolean enabled)
Enables using light touches to make a selection and activate mouseovers.
public
synchronized
void
setLoadsImagesAutomatically(boolean flag)
Tell the WebView to load image resources automatically.
Parameters
flag
| True if the WebView should load images automatically.
|
public
synchronized
void
setMinimumFontSize(int size)
Set the minimum font size.
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)
Set the minimum logical font size.
Parameters
size
| A non-negative integer between 1 and 72.
Any number outside the specified range will be pinned.
|
public
void
setNavDump(boolean enabled)
Enables dumping the pages navigation cache to a text file.
public
void
setNeedInitialFocus(boolean flag)
public
synchronized
void
setPluginsEnabled(boolean flag)
Tell the WebView to enable plugins.
Parameters
flag
| True if the WebView should load plugins.
|
public
synchronized
void
setPluginsPath(String pluginsPath)
Set a custom path to plugins used by the WebView. The client
must ensure it exists before this call.
Parameters
pluginsPath
| String path to the directory containing plugins.
|
public
synchronized
void
setRenderPriority(WebSettings.RenderPriority priority)
Set the priority of the Render thread. Unlike the other settings, this
one only needs to be called once per process.
Parameters
priority
| RenderPriority, can be normal, high or low.
|
public
synchronized
void
setSansSerifFontFamily(String font)
Set the sans-serif font family name.
public
void
setSaveFormData(boolean save)
Store whether the WebView is saving form data.
public
void
setSavePassword(boolean save)
Store whether the WebView is saving password.
public
synchronized
void
setSerifFontFamily(String font)
Set the serif font family name.
public
synchronized
void
setStandardFontFamily(String font)
Set the standard font family name.
public
synchronized
void
setSupportMultipleWindows(boolean support)
public
void
setSupportZoom(boolean support)
Set whether the WebView supports zoom
Set the text size of the page.
Parameters
t
| A TextSize value for increasing or decreasing the text. |
public
synchronized
void
setUseDoubleTree(boolean use)
Tell the WebView to use the double tree rendering algorithm.
Parameters
use
| True if the WebView is to use double tree rendering, false
otherwise.
|
public
synchronized
void
setUseWideViewPort(boolean use)
Tell the WebView to use the wide viewport
public
synchronized
void
setUserAgent(int ua)
Tell 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.
2 if the WebView should use an iPhone user-agent string.
|
public
synchronized
boolean
supportMultipleWindows()
public
boolean
supportZoom()
Returns whether the WebView supports zoom