activity切换效果theme分析

1.关于博客动画效果制作

有很多有耐心,而且乐于分享的博友,不管是自己学习的经验还是研究成果都喜欢分享知识,尤其是技术的分享。看来我们都崇尚开源。对于技术类的文章,多数人喜欢先看到技术实现的效果,而后研究代码。文字的描述总没有图片演示来得直接。笔者也一直想做一些动画演示效果,这里说说怎么制作博客中的演示动画,其实像这类的功能直接用一些小工具就可以了。有朋友问到我动画是怎么做的,其实只是我用了工具而已。

1、(生成动画的工具:Ulead GIF Animator),可以将单独的图片生成为GIF动画。

2、(动画录制工具:灵者Gif录制v1.0),可录制电脑上的一个区域,生成GIF动画。

3、直接PS,笔者因为做android开发,有一些PS功底。

2.关于activity切换效果演示

    
Activity从下方切入手机屏幕中,Activity从左到右切入手机屏幕中。
当然也有透明变幻,斜着切入等等效果。

3.关于activity切换效果实现

(1)设计android的animation在res/anim(没有可以新建)文件夹下

activity_new.xml

<span style="font-family:SimSun;font-size:10px;"><?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate 
        android:duration="@android:integer/config_shortAnimTime" 
        android:fromXDelta="100.0%" 
        android:toXDelta="0.0" />
</set></span>
activity_finish.xml

<?xml version="1.0" encoding="utf-8"?>
<set  xmlns:android="http://schemas.android.com/apk/res/android">
    <translate 
        android:duration="@android:integer/config_shortAnimTime" 
        android:fromXDelta="0.0" 
        android:toXDelta="-100.0%" />
</set>

上面仅仅表达了一种效果translate,也可以做alpha、scale等效果

(2)为activity设计对应效果的Style

    <style name="Default.NoTitleBar.Anim" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowAnimationStyle">@style/TranAnimation</item>
    </style> 
    <style name="TranAnimation" parent="@android:style/Animation.Activity">
        <item name="android:activityOpenEnterAnimation">@anim/activity_new</item>
        <item name="android:activityOpenExitAnimation">@anim/activity_finish</item>
        <item name="android:activityCloseEnterAnimation">@anim/activity_new</item>
        <item name="android:activityCloseExitAnimation">@anim/activity_finish</item>
        <item name="android:taskOpenEnterAnimation">@anim/activity_new</item>
        <item name="android:taskOpenExitAnimation">@anim/activity_finish</item>
        <item name="android:taskCloseEnterAnimation">@anim/activity_new</item>
        <item name="android:taskCloseExitAnimation">@anim/activity_finish</item>
    </style>
这里看着有open、close、enter、exit同时又分为Activity和task,之间有什么区别呢?

activityCloseEnterAnimation
When closing the current activity, this is the animation that is run on the next activity (which is entering the screen).

activityCloseExitAnimation
When closing the current activity, this is the animation that is run on the current activity (which is exiting the screen).

activityOpenEnterAnimation
When opening a new activity, this is the animation that is run on the next activity (which is entering the screen).

activityOpenExitAnimation
When opening a new activity, this is the animation that is run on the previous activity (which is exiting the screen).

---------------------------------------------------------------

taskCloseEnterAnimation
When opening an activity in a new task, this is the animation that is run on the activity of the old task (which is exiting the screen).

taskOpenEnterAnimation
When opening an activity in a new task, this is the animation that is run on the activity of the new task (which is entering the screen).

taskOpenExitAnimation
When opening an activity in a new task, this is the animation that is run on the activity of the old task (which is exiting the screen).

taskToBackEnterAnimation

When sending the current task to the background, this is the animation that is run on the top activity of the task behind it (which is entering the screen).


Task和Activity对应个关系:Activity、Task、应用和进程

android针对Task和Activity分别给出了四种情况,activityColseEnterAnimation(下一个activity如何进入屏幕),activityColseExitAnimation(如何闪出屏幕);activityOpenEnterAnimation(如何进入屏幕),activityOpenExitAnimation(上一个acitvity如何删除屏幕)。


(3)加入mainfest中的style

<activity 
    android:name="com.spring.mainview.SurfTabsActivity"
    android:theme="@style/Default.NoTitleBar.Anim">
</activity>


  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值