设置透明导航栏
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }
rootView中设置:
fitsSystemWindows="true"
键盘弹出模式
android:windowSoftInputMode="adjustResize" 挤压模式
但是此时遇到冲突了,键盘直接遮挡editText了。
参考:http://www.jianshu.com/p/1b22a1d2a7b8
核心代码:重写rootView中的两个方法
@Override protected boolean fitSystemWindows(Rect insets) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { insets.left = 0; insets.top = 0; insets.right = 0; } return super.fitSystemWindows(insets); } @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom())); } else { return insets; } }