我正在使用Value Animator为我的视图创建滑动动画。问题是,当子视图是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 [position]是包含EditText子视图的View
答案 0 :(得分:1)
你有没有在模拟器或真实设备上试过它?它可能因为模拟器而缓慢......