レイアウトアニメーション
Layoutアニメーションは、レイアウトが変化するたびにシステムが呼び出すプリロードアニメーション効果で、layoutアニメーションを使用するとレイアウトの変化が自然に見えるようになります.簡単に使えます.コントロールに属性を追加するだけでいいので、システムのデフォルトではlayoutアニメーションは起動しません.そのため、私たちの普段のアプリケーションではこの効果は発生しません.
もちろん、このアニメーション効果をカスタマイズするには、LayoutTransitionオブジェクトを新規作成し、setLayoutTransition()メソッドを呼び出してlayoutのアニメーションを設定する必要があります.
注:レイアウトアニメーションは、コンボコントロールのみで使用できます.
例:[線形レイアウト](Linear Layout)サブオブジェクトの表示をコントロールするアニメーション
ここでアニメーションコントローラLayoutAnimationControllerと接触するには、viewGroupのコントロールに同じアニメーションを設定する役割を果たすアニメーションコントローラをレイアウトすることを意味します.
その構築方法の1つ
もちろん、このアニメーション効果をカスタマイズするには、LayoutTransitionオブジェクトを新規作成し、setLayoutTransition()メソッドを呼び出してlayoutのアニメーションを設定する必要があります.
注:レイアウトアニメーションは、コンボコントロールのみで使用できます.
例:[線形レイアウト](Linear Layout)サブオブジェクトの表示をコントロールするアニメーション
ここでアニメーションコントローラLayoutAnimationControllerと接触するには、viewGroupのコントロールに同じアニメーションを設定する役割を果たすアニメーションコントローラをレイアウトすることを意味します.
その構築方法の1つ
public LayoutAnimationController(Animation animation, float delay) {
throw new RuntimeException("Stub!");
}
のパラメータはコントロールで されるアニメーションであり、2 のパラメータはアニメーション の であり、つまりAnimationのDurationにdelayを じたものである. ?
viewGroup.setLayoutAnimation(lac)
コード:package com.example.xuan.layoutAnimation;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.LayoutAnimationController;
import android.view.animation.ScaleAnimation;
import android.widget.LinearLayout;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceHolderFragment()).commit();
}
}
public static class PlaceHolderFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.fragment_main, container, false);
ScaleAnimation sa = new ScaleAnimation(0, 1, 0, 1);
sa.setDuration(5000);
LayoutAnimationController lac = new LayoutAnimationController(sa, 0.5f);
rootView.setLayoutAnimation(lac);
rootView.setLayoutAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
System.out.println("----->start");
}
@Override
public void onAnimationEnd(Animation animation) {
System.out.println("----->end");
}
@Override
public void onAnimationRepeat(Animation animation) {
System.out.println("----->repeat");
}
});
return rootView;
}
}
}
プロパティアニメーションには、サブスペースがシーケンスアニメーションなのか、 シーケンスアニメーションなのか、ランダムアニメーションなのか、もう つの いプロパティ があります.
lac.setOrder(LayoutAnimationController.ORDER_RANDOM);
LayoutAnimationController.ORDER_NORMAL; //
LayoutAnimationController.ORDER_REVERSE;//
LayoutAnimationController.ORDER_RANDOM//