沉浸式

 1 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
 2             int flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
 3             int flagTranslucentNavigation = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
 4             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
 5                 Window window = getWindow();
 6                 WindowManager.LayoutParams attributes = window.getAttributes();
 7                 attributes.flags |= flagTranslucentNavigation;
 8                 window.setAttributes(attributes);
 9                 getWindow().setStatusBarColor(Color.TRANSPARENT);
10             } else {
11                 Window window = getWindow();
12                 WindowManager.LayoutParams attributes = window.getAttributes();
13                 attributes.flags |= flagTranslucentStatus | flagTranslucentNavigation;
14                 window.setAttributes(attributes);
15             }
16         }

 

posted @ 2018-04-10 14:34  钱大少丶  阅读(236)  评论(0编辑  收藏  举报