我覺得你只是想從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