1. 程式人生 > >Android---控制元件View的GONE和VISIBLE動畫

Android---控制元件View的GONE和VISIBLE動畫

顯示動畫

TranslateAnimation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,     
                   Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,     
                   -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);     
           mShowAction.setDuration(500); 

隱藏動畫

mHiddenAction = new TranslateAnimation(Animation.RELATIVE
_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f); mHiddenAction.setDuration(500);

View的顯示:

view.startAnimation(mShowAction);     
view.setVisibility(View.VISIBLE
);

View的隱藏:

view.startAnimation(mHiddenAction);     
view.setVisibility(View.GONE);