我有一个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