我如何在之前设置活动的背景色setContentView
。我有一个需要花费很多时间来加载的活动,我需要保持背景为白色直到活动完成加载。
我想这正是您所需要的。
首先在values / colors.xml中定义颜色
<resources>
<color name="background">#FFFFFF </color>
</resources>
在引用该颜色的res / values中创建一个themes.xml文件:
<resources>
<style name="MyTheme" parent="@android:style/Theme.Light">
<item name="android:windowBackground">@color/background</item>
</style>
</resources>
...,然后在您的AndroidManifest.xml中将此指定为您要使用的活动的主题。
<activity
android:name=".MyActivity"
android:theme="@style/MyTheme" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句