您的位置:首页 > 移动开发 > Android开发

android应用启动画面+activity动画

2013-09-29 13:55 411 查看
避免启动应用后,出现短暂的黑屏或白屏现象。

-->启动的activity添加theme属性,并定义android:windowBackground。

<style name="AppLaucherTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/welcome_bg</item>
</style>


<activity
android:theme="@style/AppLaucherTheme"


1.theme中定义windowEnterAnimation和windowExitAnimation属性

窗口进入和退出的效果分别是通过@android:windowEnterAnimation和@android:windowExitAnimation属性

<style name="mydialog">

<item name="@android:windowEnterAnimation">@anim/dialog_enter</item>

<item name="@android:windowExitAnimation">@anim/dialog_exit</item>

</style>
2.theme中定义windowAnimationStyle属性

<style name="myact">

<item name="@android:activityOpenEnterAnimation">@anim/slide_bottom_in</item>

<item name="@android:activityOpenExitAnimation">@anim/retain</item>

<item name="@android:activityCloseEnterAnimation">@anim/retain</item>

<item name="@android:activityCloseExitAnimation">@anim/slide_bottom_out</item>

</style>

<style name="mytheme" parent="@android:style/Theme">

<item name="@android:windowAnimationStyle">@style/myact</item>

</style>
slide_bottom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<translate
android:duration="300"
android:fromYDelta="100.0%p"
android:toYDelta="0.0" />

</set>


slide_bottom_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<translate
android:duration="300"
android:fromYDelta="0.0"
android:toYDelta="100.0%p" />

</set>


retain.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0%p"
android:toYDelta="0%p"
android:duration="1000"/>
</set>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: