android - 将Android状态栏设置为完全透明无法正常工作
问题描述
我正在使用 Xamarin.Forms 构建我的移动应用程序,我目前在将 Android 平台中的状态栏设置为完全透明时遇到问题(就像这里的这篇文章)
因为我使用的是 xamarin.forms,所以我只想使用 Android 的styles.xml来处理这个问题
我已经阅读了这篇文章(Android 完全透明的状态栏?)以及其他一些类似的文章,并尝试了同样的方法,但我仍然无法让它正常工作。
这是我的styles.xml:
<style name="MainTheme" parent="MainTheme.Base">
</style>
<style name="SplashTheme" parent="MainTheme.Base">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="colorAccent">#FF4081</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
这是我的启动画面 xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/splash"
android:tileMode="disabled"
android:gravity="fill_horizontal|fill_vertical"
/>
</item>
</layer-list>
我能够通过状态栏获得我想要的结果,但是导航栏仍然存在问题。图片在这里:
如图所示,导航栏占据了我的应用内容的空间。
此外,当我更改android:windowTranslucentNavigation
为 false 时,它会在此处产生类似此图像的结果,条的位置正确但颜色很烂
我还需要将条的内容颜色更改为较深的颜色,而不是像这些图像那样的白色。
所以我的问题是我怎样才能让我的状态栏颜色完全透明,我的导航栏像我的前两张图片一样半透明,它们的位置就像我的最后一张图片一样,只需在 styles.xml 中设置
我感谢您的所有帮助。
解决方案
推荐阅读
- java - EditText 在 Moto 360 上无法正常工作
- javascript - 在我的代码中,我正在尝试创建房间,但我不知道为什么每次它都会用新房间创建旧房间
- javascript - Sails-mongo 的 Sails.js“无法拆除 ORM 钩子”错误
- python - 通过 SSH 配置多台机器的集中式 python 脚本
- android - Android 是否会在更新时清理应用缓存?
- java - Spring initializr 生成的 Spring Boot 应用程序在 eclipse 上运行时出错
- dart - Flutter 导入包/插件
- git - 从文件的先前版本传输部分?
- xsl-fo - How to correctly tag table border with XSL:FO and Apache FOP
- html - 将 Javascript 翻译成哈巴狗