2016-12-07 8 views
0

Ich möchte Links Rechts-Ansicht mit Animation Ändern der Größe von X 0, jetzt habe ich diese Klasse erstellt:rechts nach links 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(); 
    } 
} 

als ich benutze:

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

Aber diese Größe ändert sich von links nach rechts, jetzt verstehe ich nicht, wie ich das umkehren könnte, könnte mir jemand den Weg zeigen?

Danke.

Antwort

0

ich mit diesem gelöst haben:

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); 
Verwandte Themen