public interface WebConfig
WebView object.| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
PRIORITY_CACHE_EXPIRED_FIRST |
Indicates that the
WebView loads resources from the cache in preference to network as long as resources
are available in the cache (even if they have expired). |
static int |
PRIORITY_CACHE_FIRST |
Indicates that the
WebView loads resources from the cache in preference to the network. |
static int |
PRIORITY_CACHE_ONLY |
Indicates that the
WebView loads resources from the cache only. |
static int |
PRIORITY_NETWORK_ONLY |
Indicates that the
WebView loads resources from the network only. |
static int |
SECURITY_ALLOW |
Indicates that the
WebView will allow a secure source to load content from other sources even from an
insecure source. |
static int |
SECURITY_NOT_ALLOW |
Indicates that the
WebView will not allow a secure source to load content from an insecure source. |
static int |
SECURITY_SELF_ADAPTIVE |
Indicates that the
WebView will adopt an adaptive mode to load content from an insecure source. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
getDefaultEncoding() |
Obtains the default encoding of the
WebView. |
int |
getSecurityMode() |
Obtains the security mode in which the
WebView loads resources. |
String |
getUserAgent() |
Obtains the current
UserAgent. |
int |
getWebCachePriority() |
Obtains the priority by which
WebView loads resources from the cache and the network. |
boolean |
isAutoFitOnLoad() |
Checks whether the
WebView automatically fits the screen width when loading a page. |
boolean |
isDataAbilityPermitted() |
Checks whether access to the Data ability is allowed in the
WebView. |
boolean |
isJavaScriptPermitted() |
Checks whether JavaScript execution is enabled.
|
boolean |
isLoadsImagesPermitted() |
Checks whether the
WebView is allowed to load image resources. |
boolean |
isMediaAutoReplay() |
Checks whether the
WebView automatically plays the media file on the current page. |
boolean |
isSupportWebSql() |
Checks whether the page supports SQL database APIs.
|
boolean |
isTextAutoSizing() |
Checks whether auto text sizing is enabled.
|
boolean |
isViewPortFitScreen() |
Checks whether the viewport fits the screen width.
|
boolean |
isWebStoragePermitted() |
Checks whether web storage (also known as HTML5 DOM storage) is enabled.
|
void |
setAutoFitOnLoad(boolean isAutoFit) |
Sets whether the
WebView automatically fits the screen width when loading a page. |
void |
setDataAbilityPermit(boolean isPermitted) |
Sets whether to allow the access to the Data ability in the
WebView. |
void |
setDefaultEncoding(String encoding) |
Sets the default encoding of the
WebView. |
void |
setFocusFirstNode(boolean isFocus) |
Sets whether the content on the page is focusable when
WebView#requestFocus of the WebView is
called. |
void |
setJavaScriptPermit(boolean isPermitted) |
Sets whether to enable JavaScript in the
WebView. |
void |
setLoadsImagesPermit(boolean isPermitted) |
Sets whether to allow the
WebView to load image resources. |
void |
setLocationPermit(boolean isPermitted) |
Sets whether to enable locating for the
WebView. |
void |
setMediaAutoReplay(boolean isPermitted) |
Sets whether to enable the
WebView to automatically play the media file on the current page when the page
is opened. |
void |
setSecurityMode(int securityMode) |
Sets the security policy for the
WebView to load resources. |
void |
setSupportWebSql(boolean isSupport) |
Sets whether the page supports SQL database APIs.
|
void |
setTextAutoSizing(boolean isTextAutoSizing) |
Sets whether to enable auto text sizing.
|
void |
setUserAgent(String userAgent) |
Sets the
UserAgent, which will use the default value if the input string is null or empty. |
void |
setViewPortFitScreen(boolean isFitScreen) |
Sets whether the viewport fits the screen width.
|
void |
setWebCachePriority(int priority) |
Sets the priority for the
WebView to load resources from the cache and the network when cached resources
are valid or have expired. |
void |
setWebStoragePermit(boolean isPermitted) |
Sets whether to enable HTML5 DOM storage.
|
static final int PRIORITY_CACHE_EXPIRED_FIRST
WebView loads resources from the cache in preference to network as long as resources
are available in the cache (even if they have expired).
This constant is used by setWebCachePriority(int).
static final int PRIORITY_CACHE_FIRST
WebView loads resources from the cache in preference to the network.
This constant is used by setWebCachePriority(int).
static final int PRIORITY_CACHE_ONLY
WebView loads resources from the cache only.
This constant is used by setWebCachePriority(int).
static final int PRIORITY_NETWORK_ONLY
WebView loads resources from the network only.
This constant is used by setWebCachePriority(int).
static final int SECURITY_ALLOW
WebView will allow a secure source to load content from other sources even from an
insecure source.
This constant is used by setSecurityMode(int).
static final int SECURITY_NOT_ALLOW
WebView will not allow a secure source to load content from an insecure source.
This constant is used by setSecurityMode(int).
static final int SECURITY_SELF_ADAPTIVE
WebView will adopt an adaptive mode to load content from an insecure source.
This constant is used by setSecurityMode(int).
void setDataAbilityPermit(boolean isPermitted)
WebView.
If the access is allowed, the WebView will be able to load content from the Data ability installed in
the system.
isPermitted - Specifies whether the access is allowed. The default value is true.void setJavaScriptPermit(boolean isPermitted)
WebView.isPermitted - Specifies whether JavaScript is enabled. The default value is false.void setWebStoragePermit(boolean isPermitted)
isPermitted - Specifies whether HTML5 DOM storage is enabled. The default value is false.void setLocationPermit(boolean isPermitted)
WebView.isPermitted - Specifies whether locating is enabled. The default value is true.void setLoadsImagesPermit(boolean isPermitted)
WebView to load image resources.isPermitted - Specifies whether image resource loading is allowed. The default value is true.void setMediaAutoReplay(boolean isPermitted)
WebView to automatically play the media file on the current page when the page
is opened.isPermitted - Specifies whether media playback is enabled. The default value is false.void setSecurityMode(int securityMode)
WebView to load resources.securityMode - Indicates the security mode to use, which can be WebConfig#SECURITY_ALLOW,
WebConfig#SECURITY_NOT_ALLOW, or WebConfig#SECURITY_SELF_ADAPTIVE.boolean isDataAbilityPermitted()
WebView.true if the access is allowed; returns false otherwise.boolean isJavaScriptPermitted()
true if JavaScript execution is enabled; returns false otherwise.boolean isWebStoragePermitted()
true if web storage is enabled; returns false otherwise.boolean isLoadsImagesPermitted()
WebView is allowed to load image resources.true if loading image resources is allowed; returns false otherwise.boolean isMediaAutoReplay()
WebView automatically plays the media file on the current page.true if automatic media playback is enabled; returns false otherwise.int getSecurityMode()
WebView loads resources. The security mode can be
SECURITY_ALLOW, SECURITY_NOT_ALLOW, or SECURITY_SELF_ADAPTIVE.setSecurityMode(int)void setAutoFitOnLoad(boolean isAutoFit)
WebView automatically fits the screen width when loading a page.isAutoFit - Specifies whether the WebView automatically fits the screen width. Value true
indicates that the WebView automatically fits the screen width, and value false indicates the
opposite. The default value is false.boolean isAutoFitOnLoad()
WebView automatically fits the screen width when loading a page.true if the WebView automatically fits the screen width; returns false
otherwise.void setViewPortFitScreen(boolean isFitScreen)
isFitScreen - Specifies whether the viewport fits the screen width. The default value is true, in
which case the viewport fits the screen width.boolean isViewPortFitScreen()
true if the viewport fits the screen width; returns false otherwise.void setWebCachePriority(int priority)
WebView to load resources from the cache and the network when cached resources
are valid or have expired.priority - Indicates the priority for the WebView to load resources. The value can be
PRIORITY_CACHE_FIRST, PRIORITY_CACHE_EXPIRED_FIRST, PRIORITY_NETWORK_ONLY, or
PRIORITY_CACHE_ONLY. The default value is PRIORITY_CACHE_FIRST.int getWebCachePriority()
WebView loads resources from the cache and the network. The value can be
PRIORITY_CACHE_FIRST, PRIORITY_CACHE_EXPIRED_FIRST, PRIORITY_NETWORK_ONLY, or
PRIORITY_CACHE_ONLY.WebView loads resources.void setSupportWebSql(boolean isSupport)
isSupport - Specifies whether SQL database APIs are supported. Value true indicates that SQL
database APIs are supported, and value false indicates the opposite.boolean isSupportWebSql()
true if the page supports SQL database APIs; returns false otherwise.void setFocusFirstNode(boolean isFocus)
WebView#requestFocus of the WebView is
called.isFocus - Specifies whether the content on the page is focusable. Value true indicates that the
content is focusable, and value false indicates the opposite.void setDefaultEncoding(String encoding)
WebView.encoding - Indicates the encoding. The default value is UTF-8.String getDefaultEncoding()
WebView.void setTextAutoSizing(boolean isTextAutoSizing)
isTextAutoSizing - Specifies whether to enable auto text sizing. true indicates auto text sizing is
enabled, and false (default value) indicates the opposite case.boolean isTextAutoSizing()
true if auto text sizing is enabled; returns false otherwise.void setUserAgent(String userAgent)
UserAgent, which will use the default value if the input string is null or empty.userAgent - Indicates the UserAgent to set. This parameter can be null.String getUserAgent()
UserAgent.UserAgent.