Search in sources :

Example 1 with ChangeImageTransform

use of com.transitionseverywhere.ChangeImageTransform 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 = (ViewGroup) view.findViewById(R.id.transitions_container);
    final ImageView 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(com.transitionseverywhere.TransitionSet) ViewGroup(android.view.ViewGroup) ChangeBounds(com.transitionseverywhere.ChangeBounds) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ChangeImageTransform(com.transitionseverywhere.ChangeImageTransform) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 ChangeBounds (com.transitionseverywhere.ChangeBounds)1 ChangeImageTransform (com.transitionseverywhere.ChangeImageTransform)1 TransitionSet (com.transitionseverywhere.TransitionSet)1