Android沉浸式以及虚拟键冲突的解决方法和隐藏状态栏、标题栏的实现

手机只有虚拟键(例如:华为),并且还不能关闭,

导致的问题就是底部导航栏无法点击,

使用沉浸式就可以解决这种问题……

看代码:


不同的API使用不同的style即可;


styles 

[html]  view plain  copy
  1. <style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">  
  2.        <!--在Android 4.4之前的版本上运行,直接跟随系统主题-->  
  3.        <item name="windowActionBar">false</item>  
  4.        <item name="windowNoTitle">true</item>  
  5.    </style>  

styles-v19

[html]  view plain  copy
  1. <style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">  
  2.        <item name="android:windowTranslucentStatus">true</item>  
  3.        <item name="android:windowTranslucentNavigation">false</item>  
  4.    </style>  

styles-v21

[html]  view plain  copy
  1. <style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">  
  2.         <item name="android:windowTranslucentStatus">true</item>  
  3.         <item name="android:windowTranslucentNavigation">false</item>  
  4.         <!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色-->  
  5.         <item name="android:statusBarColor">@android:color/transparent</item>  
  6.     </style>  

设置app theme:

[html]  view plain  copy
  1. <application  
  2.         android:name=".utils.MyApplication"  
  3.         android:allowBackup="true"  
  4.         android:icon="@mipmap/icon"  
  5.         android:label="@string/app_name"  
  6.         android:supportsRtl="true"  
  7.         android:theme="@style/ImageTranslucentTheme">  

隐藏状态栏、标题栏看这里……


  1. <!-- Application theme. -->  
  2. <style name="AppTheme" parent="AppBaseTheme">  
  3.     <!-- All customizations that are NOT specific to a particular API-level can go here. -->  
  4.     <!-- 隐藏状态栏 -->  
  5.     <item name="android:windowFullscreen">true</item>  
  6.     <!-- 隐藏标题栏 -->  
  7.     <item name="android:windowNoTitle">true</item>  
  8. </style>  




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个小狼娃

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值