首页 > 代码库 > 为Activity设置开启关闭动画
为Activity设置开启关闭动画
自己为Activity做的启动、关闭动画。
在AndroidManifest.xml中
<activity android:name="com.test.PrizeActivity" android:theme="@style/activity_styleprize"/>
在res/values/styles.xml中设置activity_styleprize
<style name="activity_styleprize"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowIsTranslucent">true</item> <!-- Note that we use the base animation style here (that is no animations) because we really have no idea how this kind of activity will be used. --> <item name="android:windowAnimationStyle">@style/AnimationActivity</item> </style> <style name="AnimationActivity" parent="@android:style/Animation"> <item name="android:activityOpenEnterAnimation">@anim/activity_open</item> <item name="android:activityOpenExitAnimation">@anim/activity_close</item> <item name="android:activityCloseEnterAnimation">@anim/activity_open</item> <item name="android:activityCloseExitAnimation">@anim/activity_close</item> </style>
activity_open.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="1500" android:fromYDelta="100%p" android:toYDelta="0" /> </set>
activity_close.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="1500" android:fromYDelta="25" android:toYDelta="100%p" /> </set>
Intent intent = new Intent(); PrizeModel prizeModel=(PrizeModel) msg.obj; intent.setClass(YaoActivity.this,PrizeActivity.class); YaoActivity.this.startActivity(intent); YaoActivity.this.overridePendingTransition(R.anim.activity_open,R.anim.activity_close);
为Activity设置开启关闭动画
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。