【发布时间】:2012-07-11 22:12:15
【问题描述】:
缩放动画后的视图,尚未调整到新位置。
我使用 android 动画 (ScaleAnimation) 将布局(启动时的屏幕大小)缩放到自身大小的 0.95 倍,并且比例参考屏幕中心点。
final AnimationListener al2 = new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation arg0) {
}
};
public void animScale(){
ScaleAnimation sa = new ScaleAnimation(1,0.95f,1,0.95f, topLayout.getMeasuredWidth()/2, topLayout.getMeasuredHeight()/2);
sa.setDuration(500);
sa.setFillEnabled(true);
sa.setFillAfter(true);
sa.setAnimationListener(al2);
topLayout.startAnimation(sa);
}
public void onCreate(Bundle savedInstanceState) {
scaleButton = (Button) findViewById(R.id.scaleButton);
scaleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
animScale();
}
});
}
在此动画之后,我的布局已更改为新位置,但是当我再次单击按钮时
布局总是从屏幕尺寸缩放到 0.95 倍。
向我展示布局永远不会通过动画改变实际大小。
我需要在动画监听器动画结尾添加什么代码?
我希望在我点击按钮时实现它, 屏幕尺寸 -> 屏幕尺寸 *0.95 -> 屏幕尺寸 *0.95^2 ->........
非常感谢。
【问题讨论】: