WebSettingsCompat
open class WebSettingsCompat
kotlin.Any | |
↳ | androidx.webkit.WebSettingsCompat |
Compatibility version of android.webkit.WebSettings
Summary
Constants | |
---|---|
static Int |
In this mode WebView content will be darkened by a user agent unless web page supports dark theme. |
static Int |
In this mode WebView content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. |
static Int |
In this mode WebView content will always be darkened using dark theme provided by web page. |
static Int |
Enable force dark dependent on the state of the WebView parent view. |
static Int |
Disable force dark, irrespective of the force dark mode of the WebView parent. |
static Int |
Unconditionally enable force dark. |
Public methods | |
---|---|
open static Int |
getDisabledActionModeMenuItems(@NonNull settings: WebSettings) Gets the action mode menu items that are disabled, expressed in an integer field flag. |
open static Int |
getForceDark(@NonNull settings: WebSettings) Get the force dark mode for this WebView. |
open static Int |
getForceDarkStrategy(@NonNull settings: WebSettings) Get how content is darkened for this WebView. |
open static Boolean |
getOffscreenPreRaster(@NonNull settings: WebSettings) Gets whether this WebView should raster tiles when it is offscreen but attached to a window. |
open static Boolean |
getSafeBrowsingEnabled(@NonNull settings: WebSettings) Gets whether Safe Browsing is enabled. |
open static Unit |
setDisabledActionModeMenuItems(@NonNull settings: WebSettings, : Int) Disables the action mode menu items according to |
open static Unit |
setForceDark(@NonNull settings: WebSettings, forceDarkMode: Int) Set the force dark mode for this WebView. |
open static Unit |
setForceDarkStrategy(@NonNull settings: WebSettings, forceDarkBehavior: Int) Set how WebView content should be darkened. |
open static Unit |
setOffscreenPreRaster(@NonNull settings: WebSettings, enabled: Boolean) Sets whether this WebView should raster tiles when it is offscreen but attached to a window. |
open static Unit |
setSafeBrowsingEnabled(@NonNull settings: WebSettings, enabled: Boolean) Sets whether Safe Browsing is enabled. |
Constants
DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING
static val DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING: Int
In this mode WebView content will be darkened by a user agent unless web page supports dark theme. WebView determines whether web pages supports dark theme by the presence of color-scheme
metadata containing "dark" value. For example, <meta name="color-scheme" content="dark light">"
. If the metadata is not presented WebView content will be darkened by a user agent and prefers-color-scheme
media query will evaluate to light.
See specification for more information.
Value: WebSettingsBoundaryInterface.ForceDarkBehavior.PREFER_MEDIA_QUERY_OVER_FORCE_DARK
See Also
DARK_STRATEGY_USER_AGENT_DARKENING_ONLY
static val DARK_STRATEGY_USER_AGENT_DARKENING_ONLY: Int
In this mode WebView content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. To avoid mixing two different darkening strategies, the prefers-color-scheme
media query will evaluate to light.
See specification for more information.
Value: WebSettingsBoundaryInterface.ForceDarkBehavior.FORCE_DARK_ONLY
See Also
DARK_STRATEGY_WEB_THEME_DARKENING_ONLY
static val DARK_STRATEGY_WEB_THEME_DARKENING_ONLY: Int
In this mode WebView content will always be darkened using dark theme provided by web page. If web page does not provide dark theme support WebView content will be rendered with a default theme.
See specification for more information.
Value: WebSettingsBoundaryInterface.ForceDarkBehavior.MEDIA_QUERY_ONLY
See Also
FORCE_DARK_AUTO
static val FORCE_DARK_AUTO: Int
Enable force dark dependent on the state of the WebView parent view. If the WebView parent view is being automatically force darkened (@see android.view.View#setForceDarkAllowed), then WebView content will be rendered so as to emulate a dark theme. WebViews that are not attached to the view hierarchy will not be inverted.
If your app uses a dark theme, WebView will not be inverted. Similarly, if your app's theme inherits from a DayNight
theme, WebView will not be inverted. In either of these cases, you should control the mode manually with ForceDark#FORCE_DARK_ON
or ForceDark#FORCE_DARK_OFF
.
See Force Dark documentation for more information.
Value: WebSettings.FORCE_DARK_AUTO
See Also
FORCE_DARK_OFF
static val FORCE_DARK_OFF: Int
Disable force dark, irrespective of the force dark mode of the WebView parent. In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
Value: WebSettings.FORCE_DARK_OFF
See Also