Animation 笔记

Animation 笔记


一、TranslateAnimation

(1)、从下方移入到当前位置(移动高度为视图高度)

xml格式
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0%"
    android:toXDelta="0%"
    android:fromYDelta="100%"
    android:toYDelta="0%" 
    android:duration="500"
    android:fillAfter="true"
    android:interpolator="@android:anim/accelerate_interpolator"
    />
代码格式
openAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,       Animation.RELATIVE_TO_SELF, 0,Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);R.anim.from_down_translate);
        openAnimation.setDuration(500);
        openAnimation.setFillAfter(true);

(2)、从下方移出当前位置(移动高度为视图高度)

xml格式
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0%"
    android:toXDelta="0%"
    android:fromYDelta="0%"
    android:toYDelta="100%" 
    android:duration="500"
    android:fillAfter="true"
    android:interpolator="@android:anim/decelerate_interpolator"
    />
代码格式
closeAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f);
        closeAnimation.setDuration(500);
        closeAnimation.setFillAfter(true);

二、ScaleAnimation

(1)、以视图中心为中心,由0~1不断伸展开

xml格式
<scale 
    android:fromXScale="0"
    android:toXScale="1"
    android:fromYScale="0"
    android:toYScale="1"
    android:duration="500"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter="true"/>
代码格式
scaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(500);
scaleAnimation.setFillAfter(true);

三、组合效果

(1)、先从0~1不断展开,然后向右上角移动一个视图单位

图片的所在的真实位置是效果结束时的位置

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">  
<scale 
    android:fromXScale="0"
    android:toXScale="1"
    android:fromYScale="0"
    android:toYScale="1"
    android:duration="500"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter="true"/>

<translate 
    android:fromXDelta="-100%"
    android:toXDelta="0%"
    android:fromYDelta="100%"
    android:toYDelta="0%" 
    android:duration="500"
    android:startOffset="500"
    android:fillAfter="true"/>
</set>

(2)、先向左下角移动一个视图单位,然后从1~0不断缩小

图片的真实位置是效果开始时的位置

<translate 
    android:fromXDelta="0%"
    android:toXDelta="-100%"
    android:fromYDelta="0%"
    android:toYDelta="100%" 
    android:duration="500"
    android:fillAfter="true"/>

<scale 
    android:fromXScale="1"
    android:toXScale="0"
    android:fromYScale="1"
    android:toYScale="0"
    android:pivotX="-50%"
    android:pivotY="150%"
    android:duration="500"
    android:startOffset="500"
    android:fillAfter="true"/>

注:虽然这两个组合效果是逆向的,但是缩放效果的中心点的表达方式却不一样。
第一个是以移动前的视图为参考物的。(不是很理解)
第二个是以真实的视图为参考物的。
假设:移动是以真实视图为中心,缩放是以初始视图为中心。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Joint animation是一种用来管理角色动画中身体部位的动画的方法。在动画中,每个身体部位的动画都由一个名为C_JointAnimation的类来管理。这些身体部位可以包括右手肘、右手、左手肘、左手、右腿和左腿。同时,还可以使用一个名为JointAnimationMgr的类,将其挂载在角色的父节点下,以单独管理角色的跑步表演动画。在切换动画时,为了确保角色的动作流畅过渡,需要先重新设置Pose,然后再播放新的动画。Pose类用于保存动画层次结构中每个骨骼的变换信息,它代表了动画在给定时间点的状态。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Hands-on C++ Game Animation Programming阅读笔记(六)](https://blog.csdn.net/alexhu2010q/article/details/121463463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [unity 计时器_如何用unity 物理系统 实现Stickfight中火柴人的布娃娃效果(二)](https://blog.csdn.net/weixin_39982452/article/details/111340741)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值