检查半透明导航是否可用

时间:2013-11-05 15:47:35

标签: android

如何检查半透明导航是否可用?

我目前将其设置为半透明:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 

    translucentNavigation = true; 
    Window w = getWindow();  
    w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 

} 

但是因为我看到某些设备(例如N10)被禁用了,当然如果存在硬键就会被禁用,我想在设置FLAG之后检查它是否是半透明的或之前是否是半透明的完全可以。

1 个答案:

答案 0 :(得分:21)

在KitKat设备上,可以使用框架布尔配置资源禁用半透明系统栏。您可以在运行时检查该资源的值。

int id = getResources().getIdentifier("config_enableTranslucentDecor", "bool", "android");
if (id == 0) {
    // not on KitKat
} else {
    boolean enabled = getResources().getBoolean(id);
    // enabled = are translucent bars supported on this device
}
相关问题