Search in sources :

Example 1 with ChangeBounds

use of androidx.transition.ChangeBounds in project Transitions-Everywhere by andkulikov.

the class PathMotionSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_path, container, false);
    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            final ChangeBounds changeBounds = new ChangeBounds();
            changeBounds.setPathMotion(new ArcMotion());
            changeBounds.setDuration(500);
            TransitionManager.beginDelayedTransition(transitionsContainer, changeBounds);
            mToRightAnimation = !mToRightAnimation;
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.BOTTOM) : (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }
    });
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) ChangeBounds(androidx.transition.ChangeBounds) FrameLayout(android.widget.FrameLayout) View(android.view.View) ArcMotion(androidx.transition.ArcMotion) Nullable(androidx.annotation.Nullable)

Example 2 with ChangeBounds

use of androidx.transition.ChangeBounds in project Transitions-Everywhere by andkulikov.

the class TransitionNameSample method onCreateView.

@Nullable
@Override
@SuppressLint("DefaultLocale")
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_names, container, false);
    final ViewGroup layout = view.findViewById(R.id.transitions_container);
    final Button button = view.findViewById(R.id.button1);
    final List<String> titles = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        titles.add(String.format("Item %d", i + 1));
    }
    createViews(inflater, layout, titles);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TransitionManager.beginDelayedTransition(layout, new ChangeBounds());
            Collections.shuffle(titles);
            createViews(inflater, layout, titles);
        }
    });
    return view;
}
Also used : Button(android.widget.Button) ViewGroup(android.view.ViewGroup) ChangeBounds(androidx.transition.ChangeBounds) ArrayList(java.util.ArrayList) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint) Nullable(androidx.annotation.Nullable)

Example 3 with ChangeBounds

use of androidx.transition.ChangeBounds in project Transitions-Everywhere by andkulikov.

the class ImageTransformSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_image_transform, container, false);
    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final ImageView imageView = transitionsContainer.findViewById(R.id.image);
    imageView.setOnClickListener(new View.OnClickListener() {

        boolean mExpanded;

        @Override
        public void onClick(View v) {
            mExpanded = !mExpanded;
            TransitionManager.beginDelayedTransition(transitionsContainer, new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeImageTransform()));
            ViewGroup.LayoutParams params = imageView.getLayoutParams();
            params.height = mExpanded ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
            imageView.setLayoutParams(params);
            imageView.setScaleType(mExpanded ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER);
        }
    });
    return view;
}
Also used : TransitionSet(androidx.transition.TransitionSet) ViewGroup(android.view.ViewGroup) ChangeBounds(androidx.transition.ChangeBounds) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ChangeImageTransform(androidx.transition.ChangeImageTransform) Nullable(androidx.annotation.Nullable)

Example 4 with ChangeBounds

use of androidx.transition.ChangeBounds in project Transitions-Everywhere by andkulikov.

the class InterpolatorDurationStartDelaySample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_interpolator, container, false);
    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final View button = transitionsContainer.findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {

        boolean mToRightAnimation;

        @Override
        public void onClick(View v) {
            mToRightAnimation = !mToRightAnimation;
            Transition transition = new ChangeBounds();
            transition.setDuration(mToRightAnimation ? 700 : 300);
            transition.setInterpolator(mToRightAnimation ? new FastOutSlowInInterpolator() : new AccelerateInterpolator());
            transition.setStartDelay(mToRightAnimation ? 0 : 500);
            TransitionManager.beginDelayedTransition(transitionsContainer, transition);
            FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
            params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.TOP) : (Gravity.LEFT | Gravity.TOP);
            button.setLayoutParams(params);
        }
    });
    return view;
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ViewGroup(android.view.ViewGroup) ChangeBounds(androidx.transition.ChangeBounds) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) FrameLayout(android.widget.FrameLayout) Transition(androidx.transition.Transition) View(android.view.View) Nullable(androidx.annotation.Nullable)

Aggregations

View (android.view.View)4 ViewGroup (android.view.ViewGroup)4 Nullable (androidx.annotation.Nullable)4 ChangeBounds (androidx.transition.ChangeBounds)4 FrameLayout (android.widget.FrameLayout)2 SuppressLint (android.annotation.SuppressLint)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)1 ArcMotion (androidx.transition.ArcMotion)1 ChangeImageTransform (androidx.transition.ChangeImageTransform)1 Transition (androidx.transition.Transition)1 TransitionSet (androidx.transition.TransitionSet)1 ArrayList (java.util.ArrayList)1