/**
* 設置裝飾列表框狀態
*
* @param isOpen
* 是否打開
* @param hasAnimation
* 打開動畫
*/
private void SetResBoxState(boolean isOpen, boolean hasAnimation)
{
page.clearAnimation();
int start;
int end;
if (isOpen) {
page.setVisibility(View.VISIBLE);
start = 1;
end = 0;
} else {
page.setVisibility(View.GONE);
start = 0;
end = 1;
}
if (hasAnimation) {
AnimationSet as;
TranslateAnimation ta;
as = new AnimationSet(true);
ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, start,
Animation.RELATIVE_TO_SELF, end);
ta.setDuration(350);
as.addAnimation(ta);
page.startAnimation(as);
}
}
調用
SetResBoxState(true, true);