Android Question The most faq of all time: Move ImageView and Buttons

angelone

Member
Licensed User
Longtime User
Hi,
i read a lot of posts, but not with a real solution. I need to move an ImageView and a button by touch (FINGER).


It would be possible to DO IT without using libraries , but only by code?

Thank's a lot,
Angelo
 

Attachments

  • Cattura.PNG
    Cattura.PNG
    62 KB · Views: 278
Last edited:

eurojam

Well-Known Member
Licensed User
Longtime User
shure it is easy, just set the new position:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   Dim b As Button
   Dim m As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
  b.Initialize("b")
  b.Text="press me"
  Activity.AddView(b,0,0,100dip,100dip)
  m = False
End Sub


Sub b_Click
    If m Then
     b.Left = 0dip
     m = False
    Else
     b.Left= 100dip 
     m = True 
    End If
End Sub
 
Upvote 0

zingo

Member
Licensed User
Longtime User
Hi, I studied this example and other about moving buttons. I can't really figure out how to swap two buttons, including relative text. Actually I can't see a way to get button left and top, either. I managed to move one or more buttons with drag and drop, but I need to know their position and to swap one with another (including relative text, backcolor, etc).
I need a suggestion to understand where I'm wrong, because of course I'm missing something.
 

Attachments

  • TestForForum.zip
    8.4 KB · Views: 197
  • TestForForum.zip
    8.4 KB · Views: 171
Upvote 0
Top