欢迎使用Markdown编辑器写博客
这几天Android开发遇到布局问题,布局被手机底部的导航栏(虚拟键)挡住啦一部分。 在网上查啦一些资料,确定这几种方法能够实现。
布局中也要添加
android:fitsSystemWindows="true"
1、在Activity onCreate方法中添加 :
透明导航栏,就是下面三个虚拟按钮
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//设置导航栏透明
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
2、 设置主题 设置属性android:windowDrawsSystemBarBackgrounds为false; 会自动跳转到value-v21
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
还有就是把底部导航栏(虚拟键)给隐藏掉,我个人感觉不太好