Android判斷Navigation Bar 是否透明

來源:互聯網
上載者:User

設定Navigation Bar 透明

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

  /**     * Convenience function to set the flag bits as specified in flags, as     * per {@link #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     * {@link WindowManager.LayoutParams WindowManager.LayoutParams}     * flags.     *      * 

Note that some flags must be set before the window decoration is * created (by the first call to * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or * {@link #getDecorView()}: * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These * will be set for you based on the {@link 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上驗證通過。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.