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

The following examples show how to use android.animation.LayoutTransition#setDuration() . 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: PersistentSearchView.java    From PersistentSearchView with Apache License 2.0 7 votes vote down vote up
private void setUpLayoutTransition() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        RelativeLayout searchRoot = (RelativeLayout) findViewById(R.id.search_root);
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setDuration(DURATION_LAYOUT_TRANSITION);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            // layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
            layoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            layoutTransition.setStartDelay(LayoutTransition.CHANGING, 0);
        }
        layoutTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
        mSearchCardView.setLayoutTransition(layoutTransition);
    }
}
 
Example 2
Source File: PropertyAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 6 votes vote down vote up
private void doLayoutAnimator() {
    LayoutTransition layoutTransition = new LayoutTransition();

    layoutTransition.setAnimator(LayoutTransition.APPEARING, getObjectAnimator(false));
    layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, getObjectAnimator(true));
    layoutTransition.setDuration(2000);

    //mPuppet's parentView
    ViewGroup contentView = (ViewGroup) ((ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0);
    contentView.setLayoutTransition(layoutTransition);
    if (contentView.findViewById(R.id.view_puppet) == null) {
        contentView.addView(mPuppet);
    } else {
        contentView.removeView(mPuppet);
    }
}
 
Example 3
Source File: IndicatorDots.java    From lock-screen with MIT License 6 votes vote down vote up
private void initView(Context context) {
    if (mIndicatorType == 0) {
        for (int i = 0; i < mPinLength; i++) {
            View dot = new View(context);
            emptyDot(dot);

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mDotDiameter,
                    mDotDiameter);
            params.setMargins(mDotSpacing, 0, mDotSpacing, 0);
            dot.setLayoutParams(params);

            addView(dot);
        }
    } else if (mIndicatorType == 2) {
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setDuration(DEFAULT_ANIMATION_DURATION);
        layoutTransition.setStartDelay(layoutTransition.APPEARING, 0);
        setLayoutTransition(layoutTransition);
    }
}
 
Example 4
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
private void doLayoutAnimator() {
    LayoutTransition layoutTransition = new LayoutTransition();

    layoutTransition.setAnimator(LayoutTransition.APPEARING, getObjectAnimator(false));
    layoutTransition.setAnimator(LayoutTransition.DISAPPEARING, getObjectAnimator(true));
    layoutTransition.setDuration(2000);

    //mPuppet's parentView
    ViewGroup contentView = (ViewGroup) ((ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0);
    contentView.setLayoutTransition(layoutTransition);
    if (contentView.findViewById(R.id.view_puppet) == null) {
        contentView.addView(mPuppet);
    } else {
        contentView.removeView(mPuppet);
    }
}
 
Example 5
Source File: AnimUtil.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private static LayoutTransition a()
{
    LayoutTransition layouttransition = new LayoutTransition();
    layouttransition.setDuration(90L);
    layouttransition.setInterpolator(2, new AccelerateDecelerateInterpolator());
    layouttransition.setInterpolator(3, new AccelerateDecelerateInterpolator());
    ObjectAnimator objectanimator = ObjectAnimator.ofFloat(null, "rotationX", new float[] {
        90F, 0.0F
    }).setDuration(layouttransition.getDuration(2));
    layouttransition.setAnimator(2, objectanimator);
    objectanimator.addListener(new d());
    ObjectAnimator objectanimator1 = ObjectAnimator.ofFloat(null, "rotationX", new float[] {
        0.0F, -90F
    }).setDuration(layouttransition.getDuration(3));
    layouttransition.setAnimator(3, objectanimator1);
    objectanimator1.addListener(new e());
    return layouttransition;
}
 
Example 6
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 7
Source File: FunControl.java    From Fun with Apache License 2.0 5 votes vote down vote up
public FunControl(Builder builder){
    this.funny = builder.funny;
    this.funnyButton = builder.funnyButton;
    this.funnyContainer = builder.viewGroup;
    this.gravityToExpand = builder.gravityToExpand;
    this.widthToExpand = builder.width;

    LayoutTransition layoutTransition = funny.getLayoutTransition();
    layoutTransition.setDuration(builder.animationDuration);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
}
 
Example 8
Source File: NiboPlacesAutoCompleteSearchView.java    From Nibo with MIT License 5 votes vote down vote up
private void setUpLayoutTransition() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        RelativeLayout searchRoot = (RelativeLayout) findViewById(R.id.search_root);
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setDuration(DURATION_LAYOUT_TRANSITION);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            // layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
            layoutTransition.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
            layoutTransition.setStartDelay(LayoutTransition.CHANGING, 0);
        }
        layoutTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
        mSearchCardView.setLayoutTransition(layoutTransition);
    }
}
 
Example 9
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 10
Source File: PageIndicator.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public PageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.PageIndicator, defStyle, 0);
    mMaxWindowSize = a.getInteger(R.styleable.PageIndicator_windowSize, 15);
    mWindowRange[0] = 0;
    mWindowRange[1] = 0;
    mLayoutInflater = LayoutInflater.from(context);
    a.recycle();

    // Set the layout transition properties
    LayoutTransition transition = getLayoutTransition();
    transition.setDuration(175);
}
 
Example 11
Source File: PageIndicator.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
public PageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.PageIndicator, defStyle, 0);
    mMaxWindowSize = a.getInteger(R.styleable.PageIndicator_windowSize, 15);
    mWindowRange[0] = 0;
    mWindowRange[1] = 0;
    mLayoutInflater = LayoutInflater.from(context);
    a.recycle();

    // Set the layout transition properties
    LayoutTransition transition = getLayoutTransition();
    transition.setDuration(175);
}
 
Example 12
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 13
Source File: PageIndicator.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
public PageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.PageIndicator, defStyle, 0);
    mMaxWindowSize = a.getInteger(R.styleable.PageIndicator_windowSize, 15);
    mWindowRange[0] = 0;
    mWindowRange[1] = 0;
    mLayoutInflater = LayoutInflater.from(context);
    a.recycle();

    // Set the layout transition properties
    LayoutTransition transition = getLayoutTransition();
    transition.setDuration(175);
}
 
Example 14
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;
        }
    }
}
 
Example 15
Source File: CircularButton.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public CircularButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularButton);

    setLayoutTransition(new LayoutTransition());

    setRadius(getPx(DEFAULT_RADIUS));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(getPx(DEFAULT_ELEVATION));
    }

    mLinearLayout = new LinearLayout(context);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);

    // set selectable background
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
                                             typedValue, true);
    mSelectableItemBackground = typedValue.resourceId;
    mLinearLayout.setBackgroundResource(mSelectableItemBackground);

    // create button
    mButton = new Button(context);
    mButton.setBackgroundColor(Color.TRANSPARENT);
    mButton.setClickable(false);
    mButton.setPadding((int)getPx(15), mButton.getPaddingTop(), (int)getPx(15),
                       mButton.getPaddingBottom());
    final String text = typedArray.getString(R.styleable.CircularButton_text);
    mButton.setText(text);
    mButton.setTextColor(typedArray.getColor(R.styleable.CircularButton_textColor, Color.BLACK));

    // create progressbar
    mProgressBar = new ProgressBar(context);
    mProgressBar.setVisibility(View.GONE);

    // animation transaction
    final LayoutTransition layoutTransition = getLayoutTransition();
    layoutTransition.setDuration(DEFAULT_DURATION);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);

    this.setOnClickListener(view -> {
        if (isClickable()) {
            startLoading();
        }
    });

    // set background color animations
    mBackgroundColor = typedArray.getColorStateList(R.styleable.CardView_cardBackgroundColor)
                       .getDefaultColor();
    final ColorDrawable[] color1 = {new ColorDrawable(mBackgroundColor),
                                    new ColorDrawable(Color.WHITE)};
    mTransStartLoading = new TransitionDrawable(color1);
    final ColorDrawable[] color2 = {new ColorDrawable(mSelectableItemBackground), new
                                    ColorDrawable(mBackgroundColor)};
    mTransStopLoading = new TransitionDrawable(color2);

    // set progressbar for API < lollipop
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mProgressBar.setBackgroundColor(Color.WHITE);
        mProgressBar.getIndeterminateDrawable().setColorFilter(
            mBackgroundColor, PorterDuff.Mode.SRC_IN);
    }

    typedArray.recycle();

    // get the width set
    final int[] width = new int[] { android.R.attr.layout_width };
    final TypedArray typedArray1 = context.obtainStyledAttributes(attrs, width);
    mLayoutWidth = typedArray1.getLayoutDimension(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    typedArray1.recycle();

    mLinearLayout.addView(mButton);
    mLinearLayout.addView(mProgressBar);
    addView(mLinearLayout);
}
 
Example 16
Source File: CircularButton.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public CircularButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircularButton);

    setLayoutTransition(new LayoutTransition());

    setRadius(getPx(DEFAULT_RADIUS));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(getPx(DEFAULT_ELEVATION));
    }

    mLinearLayout = new LinearLayout(context);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);

    // set selectable background
    final TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
            typedValue, true);
    mLinearLayout.setBackgroundResource(typedValue.resourceId);

    // create button
    mButton = new Button(context);
    mButton.setBackgroundColor(Color.TRANSPARENT);
    mButton.setClickable(false);
    mButton.setPadding((int)getPx(15), mButton.getPaddingTop(), (int)getPx(15),
            mButton.getPaddingBottom());
    final String text = typedArray.getString(R.styleable.CircularButton_text);
    mButton.setText(text);
    mButton.setTextColor(typedArray.getColor(R.styleable.CircularButton_textColor, Color.BLACK));

    // create progressbar
    mProgressBar = new ProgressBar(context);
    mProgressBar.setVisibility(View.GONE);

    // animation transaction
    final LayoutTransition layoutTransition = getLayoutTransition();
    layoutTransition.setDuration(DEFAULT_DURATION);
    layoutTransition.enableTransitionType(LayoutTransition.CHANGING);

    this.setOnClickListener(view -> {
        if (isClickable()) {
            startLoading();
        }
    });

    // set background color animations
    mBackgroundColor = typedArray.getColorStateList(R.styleable.CardView_cardBackgroundColor)
            .getDefaultColor();
    mLinearLayout.setBackgroundColor(mBackgroundColor);
    final ColorDrawable[] color1 = {new ColorDrawable(mBackgroundColor),
            new ColorDrawable(Color.WHITE)};
    mTransStartLoading = new TransitionDrawable(color1);
    final ColorDrawable[] color2 = {new ColorDrawable(Color.WHITE), new
            ColorDrawable(mBackgroundColor)};
    mTransStopLoading = new TransitionDrawable(color2);

    // set progressbar for API < lollipop
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        mProgressBar.setBackgroundColor(Color.WHITE);
        mProgressBar.getIndeterminateDrawable().setColorFilter(
                mBackgroundColor, PorterDuff.Mode.SRC_IN);
    }

    typedArray.recycle();
    mLinearLayout.addView(mButton);
    mLinearLayout.addView(mProgressBar);
    addView(mLinearLayout);
}