安卓手机底部样式,也叫底部导航,也有称为底部手势条,底部小白条,底部小横条等等。通过npx @react-native-community/cli@latest init AwesomeProject
初始化项目后,安卓环境运行效果如下图:
可以看到,底部有一条黑色背景的横条。
从网上搜索到一种方案,说是修改style.xml配置,将navigationBarColor
设置为@android:color/transparent
,代码如下
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
当我尝试后发现,并没有效果,效果图如下:
又经过一番网上搜索,发现还需要设置 android:windowTranslucentNavigation
,代码如下:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
结果,底部条变成了半透明,效果图如下:
我的理解是,需要android:windowTranslucentNavigation
和android:navigationBarColor
两个参数一起配置,就可以达到控制底部条的透明效果,但是效果还不是我要的,而且透明效果也不是完全透明,而是灰色的半透明。
又搜索了半天,还是没有结果,我猜测也许无法实现像顶部栏一样的效果,于是我将底部条设置成为了白色,因为我的底部导航栏背景是白色的,所以设置成了白色,同时还需要将android:windowTranslucentNavigation
这个配置去掉,代码如下:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="android:navigationBarColor">#ffffff</item>
</style>
</resources>
我是做一个模仿boss的app,效果图如下:
最后,如果大家有其他好的方法来控制android,底部条的方案,麻烦在评论区告知一下,感谢!