我有一個LinearLayout,我希望能夠通過單擊「更多詳細信息」鏈接來顯示/隱藏。我通過調用動畫和setVisibility
moreDetailsSection.setVisibility(View.VISIBLE);
或
moreDetailsSection.setVisibility(View.GONE);
顯示/隱藏它做到這一點。這工作正常,但我想添加一個動畫,使佈局字段很好地滑動,但這隻在第一次使字段變得可見時運行,如果我隱藏它並再次顯示該字段只是突然出現。這裏是動畫代碼(moreDetailsSection是有問題的佈局):
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(250);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(150);
set.addAnimation(animation);
LayoutAnimationController controller =
new LayoutAnimationController(set, 0.25f);
moreDetailsSection.setLayoutAnimation(controller);
如何使這個運行每次我展示的佈局,而不是僅在第一次有什麼建議?
事實證明,該視圖將無法測得,而它的知名度是'GONE',所以你需要設置當您使用需要了解視圖邊界的動畫時,首先會看到「VISIBLE」。 – milosmns