use of androidx.transition.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 = 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;
}
Aggregations