私はカスタムアニメーションを使用してビューを拡大および縮小しています。これは、SOの別の回答にあります。私の問題は、ApplyTransformationが呼び出されないため、何も起こらないことです。
他に何かしていることはありますか?
private void BrandTextClicked (object sender, EventArgs e)
{
Animation animation = null;
if (expanded) {
animation = new ExpandAnimation (listView, 0, height);
} else {
animation = new ExpandAnimation(listView, height, 0);
}
animation.Duration = 500;
animation.Interpolator = new AccelerateInterpolator(1);
listView.Animation = animation;
animation.StartNow ();
listView.Invalidate ();
expanded = !expanded;
}
..。
public class ExpandAnimation : Animation {
private int mStartHeight;
private int mDeltaHeight;
private View mContent;
public ExpandAnimation(View content, int startHeight, int endHeight) : base() {
mContent = content;
mStartHeight = startHeight;
mDeltaHeight = endHeight - startHeight;
}
public override void Initialize (int width, int height, int parentWidth, int parentHeight)
{
base.Initialize (width, height, parentWidth, parentHeight);
}
protected override void ApplyTransformation(float interpolatedTime, Transformation t) {
ViewGroup.LayoutParams lp = mContent.LayoutParameters;
lp.Height = (int) (mStartHeight + mDeltaHeight *
interpolatedTime);
mContent.LayoutParameters = lp;
mContent.RequestLayout();
}
public override bool WillChangeBounds() {
return true;
}
}