在我的应用程序中,当用户启用辅助功能颜色反转模式时,我需要进行一些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;
}
关于android - 获取启用/禁用状态和可访问性颜色反转模式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44032468/