检查半透明导航功能 [英] Check if translucent navigation is available

查看:368
本文介绍了检查半透明导航功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查是否半透明导航功能?

How can I check if translucent navigation is available ?

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

I am currently setting it to translucent with:

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),当然它是禁用的,如果硬键是present,我想检查设置标志之后,如果它是半透明或之前,如果它可在所有。

But since I saw that it gets disabled for some devices (like the N10) and of course it is disabled if hardkeys are present, I'd like to check after setting the FLAG if it is translucent or before if it available at all.

推荐答案

在奇巧设​​备,半透明系统酒吧可以提供一个框架,布尔值的配置资源的禁用。您可以检查该资源在运行时的值。

On KitKat devices, translucent system bars can be disabled with a framework boolean configuration resource. You can inspect the value of that resource at runtime.

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
}

这篇关于检查半透明导航功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆