I made a viewpager with images. I want to make this fragment more effective. For example, in a chat in Telegram, when we click on a photo, another layout opens, the picture can be fully displayed in that panel, we can move it with our hands, then when we want to close it, we slide it down, then the picture sits in its place.
I want to make these transitions
public class EnlargeImageFragment extends Fragment {
ArrayList<String> imageList = new ArrayList<>();
ViewPager viewpager;
private FragmentActivity myContext;
@Override
public void onAttach(@NonNull Context context) {
myContext = (FragmentActivity) context;
super.onAttach(context);
}
@SuppressLint("ClickableViewAccessibility")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Bundle bundle = getArguments();
if (bundle != null) {
imageList = bundle.getStringArrayList("images");
}
View view = inflater.inflate(R.layout.fragment_enlarge, container, false);
viewpager = view.findViewById(R.id.viewpager);
ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(imageList, getContext());
viewpager.setAdapter(viewPagerAdapter);
viewpager.setCurrentItem(0);
return view;
}
Fragment open
FragmentManager fragmentManager = ((AppCompatActivity) context).getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.zoom_in, R.anim.zoom_out);
EnlargeImageFragment fragmentEnlargeImage = new EnlargeImageFragment();
Bundle bundle = new Bundle();
bundle.putStringArrayList("images", imageList);
fragmentEnlargeImage.setArguments(bundle);
fragmentTransaction.add(R.id.screenframe, fragmentEnlargeImage, "fragmentenlarge");
fragmentTransaction.commit();