I want to create a gallery view, in which I want to select multiple images using an orange rectangular box.
It should look something like the following:
screen look like https://i.sstatic.net/FsNAa.jpg
I want to create a gallery view, in which I want to select multiple images using an orange rectangular box.
It should look something like the following:
screen look like https://i.sstatic.net/FsNAa.jpg
Then you can define a custom adapter for your GalleryView, define a row XML layout file with ImageView and CheckBox and inflate this XML layout inside the custom adapter class. FYI, you will define custom adapter class by extending BaseAdapter
class.
Check this example: Android custom image gallery with checkbox in grid to select multiple
Doing the selection by dragging the thumbs on either sides is going to be an extra headache. First of all, handling scrolling while doing selection. Secondly, handling touch/drag and deciding whether to include an item in the selection or not.
Let me suggest a simpler way to extend your selection rectangle :
I assume the selection starts with a long click on any item. The orange selection rectangle appears over this initial item. Then a single tap on any neighboring item should include all items placed in-between the tapped and the initial item including the tapped one. That will make selection handling significantly simpler and less buggy.
Now this design shouldn't be too difficult to implement. Extend the Gallery widget and have members that indicate whether a selection is in progress and what is the range of selection (startIndex
and endIndex
) .
Override the onDraw
method and draw the selection rectangle from startIndex
to endIndex
items.
Then you can define a custom adapter for your GalleryView, define a row XML layout file with ImageView and CheckBox and inflate this XML layout inside the custom adapter class. FYI, you will define custom adapter class by extending BaseAdapter
class.
Check this example: Android custom image gallery with checkbox in grid to select multiple
What you could do:
Add to img tags
<IMG id=”1” namespace=”clicked” onclick="TriggerEvent(this)"></IMG>
Create script trigger event that changes the namespace of the selected id.
Include css to enable the borders:
.clicked{
border-style:solid;
border-width:3px;}
© 2022 - 2024 — McMap. All rights reserved.