首次打开app的时候,一般进入到加载页面。有时候我们的app在进入加载页面钱会出现短暂的黑屏或者看到一个带title的界面,虽然转瞬即逝,不过依然影响我们的感受,查阅资料后找到2种解决方案:
一般情况下通过eclipse创建的app默认的application的theme是AppTheme: android:theme="@style/AppTheme",如下所示:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
这时候我们需要修改AppTheme的样式,<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">打开@style/AppTheme后如下所示:</span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"></span><pre name="code" class="html"> <style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
现在有2种修改方案:
1.<pre> <!-- 为 Theme 设置透明属性 -->
<style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowIsTranslucent">true</item>
</style>
2.
<!-- 为 Theme 设置背景图 --> <style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@drawable/splash_bg</item>
</style>
我使用了第一种方案,有效。
参考:http://www.it165.net/pro/html/201409/22998.html
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
这时候我们需要修改AppTheme的样式,<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">打开@style/AppTheme后如下所示:</span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"></span><pre name="code" class="html"> <style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
现在有2种修改方案:
1.<pre> <!-- 为 Theme 设置透明属性 -->
<style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen"> <item name="android:windowBackground">@drawable/splash_bg</item> </style>
我使用了第一种方案,有效。
参考:http://www.it165.net/pro/html/201409/22998.html