Android ScaleAnimation and TranslateAnimation, how to avoid ScaleAnimation movement

前端 未结 4 1542
轮回少年
轮回少年 2021-02-09 19:11

I have an AnimationSet with inside a ScaleAnimation and a TranslateAnimation like this:

TranslateAnimation:

TranslateAnimation goTopFromRight =
        n         


        
4条回答
  •  失恋的感觉
    2021-02-09 19:35

    To avoid the ScaleAnimation movement when using the ScaleAnimation and TranslateAnimation, you have to multiply the TranslateAnimation parametres with those from ScaleAnimation like this:

    TranslateAnimation goRightFromTop;
    ScaleAnimation sizeNotUp;
    
    goRightFromTop  = new TranslateAnimation(0,(-( invisibleCenterImageView.getLeft() - imageViewRight.getLeft() ))*(1/0.6667f), 0, (-( invisibleCenterImageView.getTop() - imageViewRight.getTop()))*(1/0.6667f)); 
    sizeNotUp       = new ScaleAnimation(1,0.6667f,1,0.6667f,Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5); 
    

    And then, surprise you deleted the ScaleAnimation movement.

提交回复
热议问题