[英]Right to Left Resize Animation
我想用動畫從右到左,從X到0調整View的大小,現在我創建了這個類:
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);
但是這種從左到右調整大小的視圖,現在我不知道如何扭轉這種情況,有人可以給我指路嗎?
謝謝。
我已經解決了:
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.