Java android中三窗格视图动画的推荐方法?
我一直在用Android玩一些动画,和往常一样,这是一团混乱。首先,守则:Java android中三窗格视图动画的推荐方法?,java,android,animation,Java,Android,Animation,我一直在用Android玩一些动画,和往常一样,这是一团混乱。首先,守则: public class ResizeWidthAnimation extends Animation { private float mStartWeight; private float mWeight; private float mStartWeight2; private float mWeight2; private int mCurrentWidth; pri
public class ResizeWidthAnimation extends Animation {
private float mStartWeight;
private float mWeight;
private float mStartWeight2;
private float mWeight2;
private int mCurrentWidth;
private int mCurrentWidth2;
private View mView;
private int mFinalWidth2;
private View mSecondFrame;
public ResizeWidthAnimation(View view, View secondFrame, float weight, int finalWidth2) {
mView = view;
mSecondFrame = secondFrame;
mFinalWidth2 = finalWidth2;
mWeight = weight;
mStartWeight = ((LinearLayout.LayoutParams)view.getLayoutParams()).weight;
mWeight2 = weight;
mStartWeight2 = ((LinearLayout.LayoutParams)secondFrame.getLayoutParams()).weight;
mCurrentWidth = view.getMeasuredWidth();
mCurrentWidth2 = secondFrame.getMeasuredWidth();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mView.getLayoutParams();
lp.weight = (float) (mStartWeight + ((mWeight - mStartWeight) * interpolatedTime));
mView.requestLayout();
mCurrentWidth = mView.getMeasuredWidth();
if (mCurrentWidth2 >= mFinalWidth2) {
return;
}
LinearLayout.LayoutParams lp2 = (LinearLayout.LayoutParams) mSecondFrame.getLayoutParams();
lp2.weight = (float) (mStartWeight2 + ((mWeight2 - mStartWeight2) * interpolatedTime));
mSecondFrame.requestLayout();
mCurrentWidth2 = mSecondFrame.getMeasuredWidth();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}
这是一个基于两个布局权重的动画(并排放置。一个初始权重为0f,另一个为8f,第三个为2f。这应该做的是: