Ash*_*ddy 5 android accessibility inversion
在我的应用程序中,当用户启用可访问性颜色反转模式时,我需要进行一些 UI 更改。
我们是否有任何 API 可以检查 Android 中颜色反转模式的启用/禁用状态?
以下是检查可访问性反转模式的启用/禁用状态的代码。在某些手机中,反转模式将作为“负色”提供。
public boolean isInversionModeEnabled() {
boolean isInversionEnabled = false;
int accessibilityEnabled = 0;
try {
accessibilityEnabled = Settings.Secure.getInt(this.getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
} catch (SettingNotFoundException e) {
Log.d(TAG, "Error finding setting ACCESSIBILITY_DISPLAY_INVERSION_ENABLED: " + e.getMessage());
Log.d(TAG, "Checking negative color enabled status");
final String SEM_HIGH_CONTRAST = "high_contrast";
accessibilityEnabled = Settings.System.getInt(getContentResolver(), SEM_HIGH_CONTRAST, 0);
}
if (accessibilityEnabled == 1) {
Log.d(TAG, "inversion or negative colour is enabled");
isInversionEnabled = true;
} else {
Log.d(TAG, "inversion or negative colour is disabled");
}
return isInversionEnabled;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3463 次 |
最近记录: |