Android Question Moving/dragging a "view" in the panel of a HorizontalScrollView

vecino

Well-Known Member
Licensed User
Longtime User
Hi, let me see if I explain, I have an application for taking orders by waiters in restaurants, bars and the like.
It's a panel where I place labels, buttons, panels, images, etc. simulating to be tables, planters, walls, etc.
The user can adjust the objects on the screen to make it look as similar as possible to the room where the tables really are.
Among other things you can "move/drag a table" to the desired position. There is no problem with this using the "ListenTouchEvent" of the view.

The problem has arisen now that I have been asked for larger rooms and they do not fit on the device screen properly, so I have decided to change the panel where I place the views to a HorizontalScrollView.
Everything works fine, like a normal panel, but I have encountered the problem that now you can't move/drag the views on the panel because it seems to have preference the "touch" of the panel to make the scroll, and then the "touch" of the view to move/drag it doesn't work.
My question is if there is a way to disable scrolling when a view is being moved/dragged on the HorizontalScrollView panel, and re-enable it when the user has finished adjusting the "table" in place.
I hope I have explained myself.
Thank you very much.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I can't get it in any way.
With the first option I don't know if I don't do it right, but I don't get anything.
With the second option I have a problem that I don't know how to detect.
I am going to create another thread to ask about it.
Here.
Thanks, friends.
 
Last edited:
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, it just didn't work out in the end, but I don't think I understood your proposal.
If I put a panel on top of everything, that I think is not what you suggested.
If I put a panel (base panel) on top of the horizontalscrollview.panel then I understand that the different views will have to be positioned on top of the panel (base panel), and if it is invisible then also the views are not visible to be able to move them.
I repeat, surely I have not understood your proposal.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
My suggestion was to have a transparent panel on top of the HorizontalScrollview, not the internal panel.
When it is visible you can use the event of the panel to have the coordinates to move the views.
When it is invisible, you can scroll the HorizontalScrollview.
You could maybe select the view you want to move and set the cursor panel to visible and move the view.
And when it is finished reset the cursor panel to invisible to be able to scroll.
I had done this with a map in a webview to show coordinates.
There were two modes coordinates or scrolling the map.
 
Last edited:
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Let me see if I understand, you say to put a panel on top of the HorizontalScrollView. This panel is independent, that is, it is not a panel incorporated to the HorizontalScrollView.Panel.
Is it?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This panel is independent
Yes.
But you need a button, events or something else to switch the visibility on or off

Another approach would be to have a panel wider than the screen with the views and a scrollbar to move the panel, and still have the cursor panel on top.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached a small test project showing the first idea.
Checking Floor, you can move the inner panel.
Checking Cursor, you see the coordinates where the finger touches.

1679324837944.png
 

Attachments

  • HScrollViewWithCursor.zip
    11 KB · Views: 118
Upvote 0

klaus

Expert
Licensed User
Longtime User
Another approach.

The HorizontalScrollView is a little bit higher than the floor panel and the cursor panel, this is the gray line.
Moving with the finger on the gray line, scrolls the HorizontalScrollView.
Moving with the finger above it, displays the coordinates.

1679325987381.png
 

Attachments

  • HScrollViewWithCursor2.zip
    10.8 KB · Views: 89
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I have already understood your idea, thanks to your example.

This second example doesn't work for me, it doesn't do anything.

In addition I have a problem, how do I move the "Cursor" panel so that the user can move/drag the objects on it?
There is a drawback that I forgot to mention that is to blame for this problem, and that is that the users are using PDA devices that work only in portrait mode.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
To make clear the problem and what needs to be achieved.
It is that the panel is wider than the screen of the device.
Whether it is the panel of a HorizontalScrollView (in that case it scrolls and presents the part of the panel that is not seen).
And the problem arises when the user needs to move/drag the views/objects around the panel, in that case the panel does not fit on the screen and cannot be scrolled.
The solution would be to be able to scroll an "independent" panel.
The other solution is to be able to move the objects/views in the same internal panel of the HorizontalScrollView.
Thank you very much.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This second example doesn't work for me, it doesn't do anything.
On what kind of device did you test it.
I tested it on my phone, maybe the layout needs to be adjusted for bigger screens.
My goal was to show the principle on what could be done.

I understand your concern. But the problem is when you move the finger, what do you want to do, move the inner panel or move a view.
Somewhere you need to make the choice.

With the solution i posted, to move a view you need to move the inner panel to a position of interest, switch to cursor and with the coordinates move the views on the internal panel. And go back to floor to move the floor panel.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
With the solution i posted, to move a view you need to move the inner panel to a position of interest, switch to cursor and with the coordinates move the views on the internal panel. And go back to floor to move the floor panel.
Oh, that really works as you say.
And I really appreciate the work and time you are putting in to help me.
The drawback is that users are not going to be convinced by that solution, they need to be able to move objects freely around the panel, then save them and have it show up in the HorizontalScrollView as they have saved it.
So, isn't there another way to be able to scroll through a panel without having to use the internal HorizontalScrollView?

They are using PDAs similar to this one:
QpN9y3b.png
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Yes, the presentation is always vertical.
Vertical scrolling is not necessary, only horizontal scrolling is required.
klaus said:
If you have a big panel you could move it with a kind of slider.
How is it?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
In the absence of finding some system to be able to move a simple panel by scrolling, something that seems impossible, for the moment, I thought that your system could be useful for me. When I am in "edit" mode present the panel in landscape mode. And when the user is working/selling then present in portrait mode inside the HorizontalScrollView.
I hope they will accept that solution, I will wait a couple of days waiting to find some other option.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is something like this what you are looking for ?

1679338524973.png


When you click on a view, it is selected, the red frame, and pnlCursor is set to visible.
Then you can move it, when you release the finger the view is unselected and and pnlCursor is set to invisible.
When a view is selected, you can rotate it by 90°, the view is unselected after this.
 

Attachments

  • HScrollViewWithCursor.zip
    11.3 KB · Views: 87
Upvote 0
Top