Java Code Examples for android.animation.LayoutTransition#addTransitionListener()

The following examples show how to use android.animation.LayoutTransition#addTransitionListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CardStreamLinearLayout.java    From sensors-samples with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    Log.d(TAG, "onLayout: " + changed);

    if( changed && !mLayouted ){
        mLayouted = true;

        ObjectAnimator animator;
        LayoutTransition layoutTransition = new LayoutTransition();

        animator = mAnimators.getDisappearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator);

        animator = mAnimators.getAppearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.APPEARING, animator);

        layoutTransition.addTransitionListener(mTransitionListener);

        if( animator != null )
            layoutTransition.setDuration(animator.getDuration());

        setLayoutTransition(layoutTransition);

        if( mShowInitialAnimation )
            runInitialAnimations();

        if (mFirstVisibleCardTag != null) {
            scrollToCard(mFirstVisibleCardTag);
            mFirstVisibleCardTag = null;
        }
    }
}
 
Example 2
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化transition动画
 */
private void setUpLayoutTransitions() {
	mTransition = new LayoutTransition();
	//添加Layout变化监听
	mTransition.addTransitionListener(transitionListener);
	//若向ViewGroup中添加一个ImageView,ImageView对象可以设置动画(即APPEARING 动画形式),
	//ViewGroup中的其它ImageView对象此时移动到新的位置的过程中也可以设置相关的动画(即CHANGE_APPEARING 动画形式)。
	mTransition.enableTransitionType(LayoutTransition.APPEARING);
	//设置整个Layout变换动画时间
	mTransition.setDuration(300);
	layout.setLayoutTransition(mTransition);
}
 
Example 3
Source File: CardStreamLinearLayout.java    From android-play-places with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    Log.d(TAG, "onLayout: " + changed);

    if( changed && !mLayouted ){
        mLayouted = true;

        ObjectAnimator animator;
        LayoutTransition layoutTransition = new LayoutTransition();

        animator = mAnimators.getDisappearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator);

        animator = mAnimators.getAppearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.APPEARING, animator);

        layoutTransition.addTransitionListener(mTransitionListener);

        if( animator != null )
            layoutTransition.setDuration(animator.getDuration());

        setLayoutTransition(layoutTransition);

        if( mShowInitialAnimation )
            runInitialAnimations();

        if (mFirstVisibleCardTag != null) {
            scrollToCard(mFirstVisibleCardTag);
            mFirstVisibleCardTag = null;
        }
    }
}
 
Example 4
Source File: CardStreamLinearLayout.java    From android-BatchStepSensor with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    Log.d(TAG, "onLayout: " + changed);

    if( changed && !mLayouted ){
        mLayouted = true;

        ObjectAnimator animator;
        LayoutTransition layoutTransition = new LayoutTransition();

        animator = mAnimators.getDisappearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, animator);

        animator = mAnimators.getAppearingAnimator(getContext());
        layoutTransition.setAnimator(LayoutTransition.APPEARING, animator);

        layoutTransition.addTransitionListener(mTransitionListener);

        if( animator != null )
            layoutTransition.setDuration(animator.getDuration());

        setLayoutTransition(layoutTransition);

        if( mShowInitialAnimation )
            runInitialAnimations();

        if (mFirstVisibleCardTag != null) {
            scrollToCard(mFirstVisibleCardTag);
            mFirstVisibleCardTag = null;
        }
    }
}