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
Fantastic!!!
The operation seems fine to me, I believe that the client can accept the editing of the tables in that way.
Thank you very much!!!

Now there is one last drawback, the pnlFloor panel does not have the objects/views created but the objects are added to it dynamically by reading them from the database.
Then it would be necessary some way to assign it to the HorizontalScrollView panel.
I mean, in the database are the positions and sizes of the different tables and objects.
They are read and displayed in the pnlFloor panel.
Now how to do it?
hsvFloor.Panel = pnlFloor ' .LoadLayout("Floor")
Obviously, that can't be done, how would it be possible?
Thanks.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can add those in the code.
You need to define a scale for pnlFloor panel according to the room dimensions.
Then you can calculate the dimensions of the objects in pixels.
And add the views onto the panel in the code.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much, I'll try tomorrow, I've been in front of the computer for almost 14 hours today :D
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I am implementing in my application this system of editing panels. If I find any problem then I will come back to bother here :D
Thank you very much, again, it is a luxury to have the help of such expert people.
As soon as I have a working version I will post some screenshots.
THANK YOU!!!
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello friends, I am finally going to use the method proposed by klaus.
However, as I am very stubborn, I kept looking for a more comfortable method to scroll in a panel that does not fit on screen (it is the panel where the user will move/drag the objects, tables, planters, etc).
Well, I thought to try with a B4XSeekBar and I think the result is quite good.
It is very simple, the B4xSeekBar has as maximum value the width of the panel, and in the "ValueChanged" of the same one I am moving the panel.
B4X:
Private Sub B4XSeekBar1_ValueChanged (Value As Int)
    pnTrastear.Left = Value*(-1)
End Sub
I attach a video of how it works.
Thank you very much, friends.
 
Last edited:
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, yesterday I sent 2 examples to show the customer and let him decide which method he likes best to move the panel in edit mode.
I received an email a moment ago saying that he has chosen the solution proposed by Klaus. He was not convinced by the "SeekBar" option to scroll the panel.
So I will implement it that way.
Thank you very much.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It seems to be the reason, he says that they don't quite understand that you have to move that bar to move the panel.
 
Upvote 0
Top