Android平移動畫

2021-09-21 16:45:40 字數 2846 閱讀 3352

public

void

startanimation(animation animation)

執行動畫,引數可以是各種動畫的物件,animation的多型,也可以是組合動畫,後面會有。

public

translateanimation(context context, attributeset attrs)

public

translateanimation(float fromxdelta, float toxdelta, float fromydelta, float toydelta)

public

translateanimation(int fromxtype, float fromxvalue, int toxtype, float toxvalue, int fromytype, float fromyvalue, int toytype, float toyvalue)

* constructor to use when building a translateanimation from code

* the start of

the animation

theend

ofthe animation

the start of

the animation

theend

ofthe animation

*/public translateanimation(float fromxdelta, float toxdelta, float fromydelta, float toydelta)

舉例:

translateanimation ta = new translateanimation(-200,100,0,0);

ta.setduration(3000);

ta.setrepeatcount(1);

ta.setrepeatmode(translateanimation.reverse);

iv.startanimation(ta);

其它就不一一舉例了

* constructor to use when building a translateanimation from code

* * @param fromxtype specifies how fromxvalue should be interpreted. one of animation.absolute, animation.relative_to_self, or animation.relative_to_parent.

the start of

the animation. this value can either be an absolute number

if fromxtype is absolute, or a percentage (where

1.0is

100%) otherwise.

* @param toxtype specifies how toxvalue should be interpreted. one of animation.absolute, animation.relative_to_self, or animation.relative_to_parent.

theend

ofthe animation. this value can either be an absolute number

if toxtype is absolute, or a percentage (where

1.0is

100%) otherwise.

* @param fromytype specifies how fromyvalue should be interpreted. one of animation.absolute, animation.relative_to_self, or animation.relative_to_parent.

the start of

the animation. this value can either be an absolute number

if fromytype is absolute, or a percentage (where

1.0is

100%) otherwise.

* @param toytype specifies how toyvalue should be interpreted. one of animation.absolute, animation.relative_to_self, or animation.relative_to_parent.

theend

ofthe animation. this value can either be an absolute number

if toytype is absolute, or a percentage (where

1.0is

100%) otherwise.

*/public translateanimation(int fromxtype, float fromxvalue, int toxtype, float toxvalue, int fromytype, float fromyvalue, int toytype, float toyvalue)

其實這裡的第2、4、6、8個引數就是對應上面四個引數構造裡的第1、2、3、4個引數,這裡的第1、3、5、7個引數分別是第2、4、6、8個引數的型別,上面的是預設都給設定成了「absolute」型別,這裡還可以設定relative_to_self和relative_to_parent等等,就不舉例了

css 平移到某個位置 CSS3平移動畫效果

在這篇文章中主要是講如何通過css3實現平移動畫效果,在開始之前先給大家介紹一下與平移動畫有關的css3屬性以及相關的屬性描述。一 transition property 是用來指定當元素其中乙個屬性改變時執行transition效果 例如 長度,寬度,顏色等 二 transition durati...

Android動畫工具類(平移 漸顯 旋轉)

做專案的時候經常遇到一些小動畫的需求 所以決定整合乙個工具類方便以後直接呼叫 先簡單放一些專案用到的 以後有時間再更新。public class animationutil return minstance 從控制項所在位置移動到控制項的底部 隱藏 paramv param duration 動畫時...

實現盒子水平移動

引數 element 要運動的元素 targetvalue 目標值 數字 speed 速度 數字 function move element,targetvalue,speed 更新變數的值 檢測最後一步和速度計算是否能夠到達目標,若差值小於速度,則說明是最後一步,並且最後一步不能再去和speed計...