【发布时间】:2018-12-05 08:30:15
【问题描述】:
我目前正尝试在我的初始屏幕Activity 中全屏显示。我正在使用style 执行此操作,它设置在Activity 上,如下所示:
style.xml
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
AndroidManifest.xml
<activity
android:name=".Activities.SplashScreenActivity"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
您可能建议以编程方式执行此操作,但我已经尝试了来自 this、this、this、this、this 和 this 链接的所有答案。目前,没有一个程序化解决方案对我有用 - 将每个建议的修复都放在我的 splashActivity.java 的 onResume 或 onCreate 中,但状态和导航栏仍然可见。但是,当使用我的自定义 style 时,它只隐藏状态栏,导航栏保持可见。到目前为止我在 xml 文件中尝试过的内容:使用了不同的父样式,不使用背景可绘制对象,从 activity 中删除了 screenOrientation 和 noHistory。我很确定我在这里遗漏了一些东西,但我看不到什么。如果需要,可以共享更多代码。提前致谢!
【问题讨论】:
-
你的 SplashActivity 是从
AppCompatActivity扩展而来的吗? -
是的,它正在扩展 AppCompatActivity:
public class SplashScreenActivity extends AppCompatActivity -
只是为了测试一下,你能不能在 Manifest.xml 中把这个样式添加到你的应用程序节点中:
-
我收到构建错误
Attribute application@theme value=(@style/MyMaterialTheme) from AndroidManifest.xml:33:9-43 is also present at AndroidManifest.xml:33:9-43 value=(@style/SplashTheme). -
您是否在应用程序节点中定义了两次
android:theme?你能分享你的 manifest.xml 吗?
标签: android fullscreen splash-screen statusbar navigationbar