android 判断透明,Android判断Navigation Bar 是否透明

设置Navigation Bar 透明

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);或者Theme中添加  true

/**

* Convenience function to set the flag bits as specified in flags, as

* per [email protected] #setFlags}.

* @param flags The flag bits to be set.

* @see #setFlags

* @see #clearFlags

*/

public void addFlags(int flags) {

setFlags(flags, flags);

}

/**

* Set the flags of the window, as per the

* [email protected] WindowManager.LayoutParams WindowManager.LayoutParams}

* flags.

*

*

Note that some flags must be set before the window decoration is

* created (by the first call to

* [email protected] #setContentView(View, android.view.ViewGroup.LayoutParams)} or

* [email protected] #getDecorView()}:

* [email protected] WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and

* [email protected] WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These

* will be set for you based on the [email protected] android.R.attr#windowIsFloating}

* attribute.

*

* @param flags The new window flags (see WindowManager.LayoutParams).

* @param mask Which of the window flag bits to modify.

* @see #addFlags

* @see #clearFlags

*/

public void setFlags(int flags, int mask) {

final WindowManager.LayoutParams attrs = getAttributes();

attrs.flags = (attrs.flags&~mask) | (flags&mask);

if ((mask&WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0) {

attrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY;

}

mForcedWindowFlags |= mask;

if (mCallback != null) {

mCallback.onWindowAttributesChanged(attrs);

}

}

其中:attrs.flags = (attrs.flags&~mask) | (flags&mask);

谁能给解释一下这行代码的意思?以前学的都忘记了

so

public boolean existFlag(int flags){

WindowManager.LayoutParams attrs= getWindow().getAttributes();

if(attrs.flags ==( (attrs.flags&~flags) | (flags&flags))){

return true;

}

return false;

}

KitKat上验证通过。

原文:http://blog.csdn.net/huangyanan1989/article/details/25879887

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值