2016-12-07 4 views
0

Я хочу изменить размер Вид с анимацией справа налево, от X до 0, теперь я создал этот класс:справа налево Resize Animation

public class ResizeAnimationRightToLeft extends Animation { 
private View mView; 
private float mToHeight; 
private float mFromHeight; 

private float mToWidth; 
private float mFromWidth; 

    public ResizeAnimationRightToLeft(View v, float fromWidth, float fromHeight, float toWidth, float toHeight) { 
     mToHeight = toHeight; 
     mToWidth = toWidth; 
     mFromHeight = fromHeight; 
     mFromWidth = fromWidth; 
     mView = v; 
    } 

    @Override 
    protected void applyTransformation(float interpolatedTime, Transformation t) { 
     float height = 
       (mToHeight - mFromHeight) * interpolatedTime + mFromHeight; 
     float width = (mToWidth - mFromWidth) * interpolatedTime + mFromWidth; 
     ViewGroup.LayoutParams p = mView.getLayoutParams(); 
     p.height = (int) height; 
     p.width = (int) width; 
     mView.requestLayout(); 
    } 
} 

Чем я использую:

ResizeAnimationRightToLeft scale = new ResizeAnimationRightToLeft(layout, 0, DIM_HEIGHT, DIM_WIDTH, DIM_HEIGHT); 

Но это изменение размера слева направо, теперь я не понимаю, как это можно отменить, может ли кто-нибудь показать мне путь?

Спасибо.

ответ

0

Я решил с этим:

ScaleAnimation animationRightToLeft = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,1.0f, Animation.RELATIVE_TO_SELF, 0.5f); 
animationRightToLeft.setDuration(200); 

ScaleAnimation animationLeftToRight = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
animationLeftToRight.setDuration(200); 
Смежные вопросы