最近在做指南针的时候遇到了一个奇怪的现象:当一个view被旋转之后,它的setVisibility方法不再起作用了。可以参考【 http://stackoverflow.com/questions/8690029/why-doesnt-setvisibility-work-after-a-view-is-animated 】。后来根据这个帖子的方法修改掉了这个现象。备忘如下:
CONTENTS
1)初始化角度和动画旋转代码
private float currentDegree=0f; //====== //====== float degree = locDesc.direction; RotateAnimation ra=new RotateAnimation(currentDegree,-degree,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); ra.setDuration(200); ra.setFillAfter(true); image_zhinanzhen.startAnimation(ra); currentDegree=-degree;
2)设置invisible的方法,注意需要将当前角度清0。
currentDegree = 0; image_zhinanzhen.clearAnimation(); image_zhinanzhen.setVisibility(View.INVISIBLE);
发表评论