【问题标题】:Enter full-screen during splash-screen activity在闪屏活动期间进入全屏
【发布时间】: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


【解决方案1】:

这是我的 SplashScreenActivity 样式:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_logo_drawable</item>
</style>

我只使用属性windowBackground

【讨论】:

  • 这样我的状态栏隐藏了,但导航栏仍然可见。
  • 请分享您的启动活动布局
  • 我的启动活动没有布局。我像你一样只设置了我的活动使用的样式的背景,drawable 看起来像这样:pastebin.com/96igp23U
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-02
  • 2012-04-18
  • 1970-01-01
  • 1970-01-01
  • 2012-10-04
  • 1970-01-01
相关资源
最近更新 更多