Answer the question
In order to leave comments, you need to log in
How to create an image gallery with slide?
Good day to all!
Faced here with such task. Make an image gallery with slide.
I think like this:
1. Lay out an ImageView grid type screen in a RelativeLayout, for example.
2. Count the number of pictures, divide by the number that fit on one screen. This will be the number of fragments that we will add to the ViewPager.
When you click on the picture, you need to show the photo in full screen. those. you need to somehow refer to this photo
. But with such a scheme, I don’t know how to refer to a specific photo on a specific fragment.
Another option is to make the RecycleView horizontal
mRecyclerView.setLayoutManager(new GridLayoutManager(mActivity, 3));
Answer the question
In order to leave comments, you need to log in
As for me, the first option is OK. The only thing I would replace the ImageView + RelativeLayout bundle with is a self-written ViewGroup component that takes the number of columns and columns in the grid and places the child views in the right places.
The problem with understanding which ImageView was clicked on is solved simply: when you add an ImageView to the container, save the uri to the image as a tag, and when this ImageView arrives onClickListener , you will get the uri using the view.getTag() method.
While writing, I thought about a possible problem: since the ViewPager keeps 3+ pages with pictures in memory, there may be problems due to OutOfMemory, so you need to properly resize the preview of the pictures.
From my point of view, this is the easiest option (of course, if there is no ready-made solution :).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question