0
我使用Value Animator爲我的視圖創建滑動動畫。問題是,當子視圖是EditText動畫是不連貫的。代碼:Android ValueAnimator EditText波濤洶涌的動畫
private ValueAnimator SlideAnimator(int start,int end, View mView)
{
ValueAnimator animator = ValueAnimator.OfInt(start, end);
animator.SetDuration(2500);
animator.Update +=
(object sender, ValueAnimator.AnimatorUpdateEventArgs e) => {
var value = (int)animator.AnimatedValue;
ViewGroup.LayoutParams layoutParams = mView.LayoutParameters;
layoutParams.Height = value;
mView.LayoutParameters=layoutParams;
mView.RequestLayout();
};
return animator;
if (wrappedChildren[position].Visibility == ViewStates.Visible)
{
int finalHeight = wrappedChildren[position].Height;
ValueAnimator mAnimator = SlideAnimator(finalHeight, 0, wrappedChildren[position]);
mAnimator.Start();
mAnimator.AnimationEnd += (sender, args) =>
{
SetSectionVisibility(position, ViewStates.Gone);
};
}
else
{
int widthSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
wrappedChildren[position].Measure(widthSpec,heightSpec);
int measuredHeight = wrappedChildren[position].MeasuredHeight;
ValueAnimator mAnimator = SlideAnimator(0, measuredHeight,wrappedChildren[position]);
mAnimator.Start();
SetSectionVisibility(position, ViewStates.Visible);
}
wrappedChildren [位置]是查看保存的EditText子視圖