「詳細」リンクをクリックして表示/非表示にしたい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);
これは私がレイアウトだけでなく、最初の時間を表示するたびに実行ようにする方法上の任意のアドバイスはありますか?
それが判明ビューの境界を知る必要のあるアニメーションを使用するときに、最初に 'VISIBLE'の可視性を確認する必要があります。 – milosmns