How does TranslateAnimation work on Android?

前端 未结 2 1195
无人及你
无人及你 2021-02-04 00:12

I went through

TranslateAnimation (float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)

but am still confused about how T

2条回答
  •  眼角桃花
    2021-02-04 01:02

    With TranslateAnimation you can create an animation to control an object.

    With TranslateAnimation you're able to control the position of an object. You pass this 4 parameters, which stand for the X and Y coordinates.

    By Example you want to move an object to the right, you would do something like: TranslateAnimation(0.0f, 1.0f, 0.0f, 0.0f)

    (or use Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF)

    We only use the X coordinate now, because we are doing now an easy "LeftToRight" animation-move.

    Change in X coordinate to apply at the start of the animation
    toXDelta (0.0f)    
    
    Change in X coordinate to apply at the end of the animation (1.0f)
    

    = 1 to right

    Maybe take a look at http://en.wikipedia.org/wiki/Coordinate_system

提交回复
热议问题