我觉得你只是想从0高度动画着眼于它的最终高度,你可以用自定义动画做到这一点:
public class ShowAnim extends Animation {
int targetHeight;
View view;
public ShowAnim(View view, int targetHeight) {
this.view = view;
this.targetHeight = targetHeight;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
view.getLayoutParams().height = (int) (targetHeight * interpolatedTime);
view.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}
并在代码中这样做是为了启动动画:
Animation ani = new ShowAnim(headerView, 100/* target layout height */);
ani.setDuration(2000/* animation time */);
headerView.startAnimation(ani);
来源
2012-03-14 15:22:49
Kai
你想要滑块上的动画吗? – 2012-03-14 04:40:20
@Nixit Patel yes – Chrishan 2012-03-14 04:52:59
@NixitPatel:你想实现滑块动画? – 2012-03-14 05:00:02