Search in sources :

Example 1 with ArcMotion

use of androidx.transition.ArcMotion 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)

Aggregations

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 Nullable (androidx.annotation.Nullable)1 ArcMotion (androidx.transition.ArcMotion)1 ChangeBounds (androidx.transition.ChangeBounds)1