缩放动画后的视图,没有调整到新位置.
我使用安卓动画(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,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 – > ……..
非常感谢.