findViewById(android.R.id.statusBarBackground) returns null

僤鯓⒐⒋嵵緔 提交于 2019-12-04 20:44:01
KaMyLL

Snippet for those who just need a clean answer without reading the whole topic linked by T.Vert

    final View decor = getWindow().getDecorView();
    decor.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            decor.getViewTreeObserver().removeOnPreDrawListener(this);
            View statusBar = decor.findViewById(android.R.id.statusBarBackground);
            return true;
        }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!