【问题标题】:UI freezes on removing white screen before splashUI 冻结在启动前移除白屏
【发布时间】:2016-08-08 06:23:23
【问题描述】:

我正在尝试在启动前删除白屏,所以我遵循了这些链接中提到的解决方案

How To fix white screen on app Start up?

White screen before splashscreen

我几乎尝试了这里提到的所有解决方案

其中包括将活动主题更改为此

 android:theme="@android:style/Theme.Translucent.NoTitleBar"

或将其添加到我的主题中

<item name="android:windowDisablePreview">true</item>

但是实现任何这些都会在单击应用程序图标后冻结 UI 一段时间,之后一切正常。

有没有人成功解决了这个滞后问题。任何帮助将不胜感激。

【问题讨论】:

  • 不妨看看这里【启动画面模式】:bignerdranch.com/blog/splash-screens-the-right-way
  • 感谢@Shaishav 的回复,但我无法遵循此处提到的所有准则,因为我的初始屏幕是动态的,即此屏幕中的内容不断变化:(
  • 有人否决这个问题。请帮助我获得解决方案。如果您发现这个问题不恰当,请随时编辑它。谢谢。
  • @Shaishav 谢谢你的回答告诉我正确的方法。这绝对有帮助。

标签: android performance android-layout splash-screen app-startup


【解决方案1】:

创建一个自定义主题,例如,

 //splashTheme
 //create in styles
 <style name="splashTheme" parent="AppTheme">
    <!-- Customize your theme here. -->

    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

</style>

然后按如下方式应用主题,

 //manifest file
 <activity
        android:name=".SplashActivity"

        android:theme="@style/AppTheme.splashTheme"
        android:windowSoftInputMode="adjustResize|stateHidden" />

试试这个。

【讨论】:

  • 感谢您的回答,但这并没有帮助:(
  • 有什么问题?可以发截图吗?
  • 我无法截取延迟的屏幕截图。UI 在打开应用之前会挂起一段时间。延迟介于应用打开和应用图标点击之间
【解决方案2】:

以下更改在 mac 上对我有用:

1.Goto android studio preferences.
2.In Build,Execution and Deployment select "Instant run".
3.disable-Enable instant run to hot swap code/resource changes on deploy.
4.apply changes,clean project and rebuild again.

【讨论】:

  • 感谢您的回答,但请再次检查我的问题。这不是我要找的... :)
  • 在自定义样式中使用它 true 而不是 true
  • 第一个与后一个有何不同。
  • 请检查我的回答这对我有用:stackoverflow.com/questions/6325018/…
【解决方案3】:

终于得到了我的答案Splash Screen in Right Way。我只是跟随。

在 values-->styles.xml 我创建了闪屏背景图片

<style name="Splash" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
</style>

对于低于 api 19,在 values-19->styles.xml 中我使用了

<style name="Splash" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

我从 SplashActivity 中删除了 setContentview() 并在 Manifest.xml 文件 android:theme="@style/Splash" 中添加了启动屏幕的样式

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-24
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多