WebSettings.AlgorithmicDarkeningAllowed 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取此 WebView 是否允许算法变暗。 - 或 - 控制是否允许算法变暗。
public virtual bool AlgorithmicDarkeningAllowed { [Android.Runtime.Register("isAlgorithmicDarkeningAllowed", "()Z", "GetIsAlgorithmicDarkeningAllowedHandler", ApiSince=33)] get; [Android.Runtime.Register("setAlgorithmicDarkeningAllowed", "(Z)V", "GetSetAlgorithmicDarkeningAllowed_ZHandler", ApiSince=33)] set; }
[<get: Android.Runtime.Register("isAlgorithmicDarkeningAllowed", "()Z", "GetIsAlgorithmicDarkeningAllowedHandler", ApiSince=33)>]
[<set: Android.Runtime.Register("setAlgorithmicDarkeningAllowed", "(Z)V", "GetSetAlgorithmicDarkeningAllowed_ZHandler", ApiSince=33)>]
member this.AlgorithmicDarkeningAllowed : bool with get, set
属性值
如果允许或不允许算法变暗。
- 特性
注解
属性 getter 文档:
获取此 WebView 是否允许算法变暗。 默认值为 false。
Java文档android.webkit.WebSettings.isAlgorithmicDarkeningAllowed()。
属性 setter 文档:
控制是否允许算法变暗。
注意: 此 API 和描述的行为仅适用于具有 targetSdkVersion ≥ android.os.Build.VERSION_CODES#TIRAMISU的应用。
WebView 始终根据应用的主题属性prefers-color-scheme(即 android.R.styleable#Theme_isLightTheme isLightThemeprefers-color-scheme isLightTheme 为 true 或未指定)设置媒体查询light,否则为 dark。 这意味着,如果内容支持,Web 内容的浅色或深色样式将自动应用以匹配应用的主题。
默认情况下不允许算法变暗。
如果应用的主题为深色且允许算法变暗,则 WebView 将尝试使用算法使 Web 内容变暗,如果内容未定义自己的深色样式,并且不会显式禁用深色。
如果 Android 正在向 WebView 应用强制深色,则 WebView 将忽略此设置的值,其行为就像设置为 true 一样。
弃用 #setForceDark 和相关 API 在具有 targetSdkVersion ≥ android.os.Build.VERSION_CODES#TIRAMISU的应用中没有操作,但它们仍适用于具有 targetSdkVersion<android.os.Build.VERSION_CODES#TIRAMISU的应用。
下表总结了 API 如何处理不同的应用。
<table border=“2” width=“85%” align=“center” cellpadding=“5”><thead><tr<>th>App/th><>Web content, use /th><>Web content<prefers-color-scheme which not use<prefers-color-scheme /th<>/tr></thead<>tbody><<>td>App< with isLightTheme True or not set</td<>td>Renders with the light theme defined by the content author.</td><td td>呈现器,其默认样式由内容作者定义。</td></tr><tr><td>App with Android forceDark in effect</td><td>Renders with the dark theme defined by the content author.</td><td Td>呈现,如果内容作者允许,则算法将样式修改为深色。</td></tr>><<td>App with isLightTheme False,android.os.Build.VERSION_CODES#TIRAMISU<targetSdkVersion and has<FORCE_DARK_AUTO /td<>td>Renders with the dark theme defined by the content author.</td><td td>呈现器,其默认样式由内容作者定义。</td></tr><><td>App with isLightTheme False, targetSdkVersion ≥ android.os.Build.VERSION_CODES#TIRAMISU和<setAlgorithmicDarkening(false) /td<>td td>Renders with the dark theme defined by the content author.</td><td td>呈现器,其默认样式由内容作者定义。</td></tr><><td>App with isLightTheme False, targetSdkVersion ≥ android.os.Build.VERSION_CODES#TIRAMISU和<setAlgorithmicDarkening(true) /td<>td td>Renders with the dark theme defined by the content author.</td><td Td>呈现,如果内容作者允许,则算法将样式修改为深色。</td></tr></tbody></table>
Java文档android.webkit.WebSettings.setAlgorithmicDarkeningAllowed(boolean)。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。