【问题标题】:Android blank layout appears before background imageAndroid空白布局出现在背景图片之前
【发布时间】:2014-10-11 18:40:53
【问题描述】:

对不起,我确定这是非常基本的东西。

在我的应用启动到的活动中,我的布局的 XML 如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background2x"
    android:id="@+id/mainScreen"
    tools:context="com.offyear.www.offyear.WelcomeActivity">

我遇到的问题是屏幕没有立即加载到我设置的背景图像。在背景图像和按钮出现之前,它首先加载到空白屏幕大约半秒。当然,这并没有破坏我的应用程序的功能或任何东西,但它很烦人并且看起来很草率。

我需要怎么做才能没有初始空白屏幕?当我的应用启动时,用户首先应该看到的是背景图片和按钮。

感谢并为 Android 101 问题道歉。

【问题讨论】:

标签: android layout background


【解决方案1】:

在设置背景时提高性能和“速度”的最佳方法是将您想要的任何内容作为背景添加到您的活动使用的主题中。这是因为 Android 会先绘制主题中的所有内容,然后才会绘制根布局和背景。

如果您有时间,可以观看 Cyril Mottier 的视频,了解如何在处理可绘制对象时改进您的实现。他为这些场景提供了非常好的提示和建议:

https://www.parleys.com/play/528e806ae4b054cd7d2ef4a5/chapter50/about

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    相关资源
    最近更新 更多