Hi, I am new at B4A. So can you please help me with my problem ? I would like to make program with floating panels, whitch could be resized like in designer. So I used draggable view for moving panels and it is works fine. Then I tried to define 8 small button in panel and set him fixed possitions on the edge of panel. (Like the red squares in abstract designer). But if I run the program, 8 panels are bring together in one corner and still have no idea, how to make that panel resizable. There is "my" code for the class module:
And the main one:
Could somebody please help me ?
Thank you. And sorry for my bad english
B4X:
'Class module
Sub Class_Globals
Private innerView As View
Private panel1 As Panel
Private downx, downy As Int
Private ACTION_DOWN, ACTION_MOVE, ACTION_UP As Int
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Activity As Activity, v As View)
innerView = v
panel1.Initialize("")
panel1.Color = Colors.Transparent
Activity.AddView(panel1, v.Left, v.Top, v.Width, v.Height)
ACTION_DOWN = Activity.ACTION_DOWN
ACTION_MOVE = Activity.ACTION_MOVE
ACTION_UP = Activity.ACTION_UP
Dim r As Reflector
r.Target = panel1
r.SetOnTouchListener("panel1_Touch")
End Sub
Private Sub Panel1_Touch( o As Object, ACTION As Int, x As Float, y As Float, motion As Object) As Boolean
If ACTION = ACTION_DOWN Then
downx = x
downy = y
Else
innerView.Left = innerView.Left + x - downx
innerView.Top = innerView.Top + y - downy
panel1.Top = innerView.Top
panel1.Left = innerView.Left
End If
Return True
End Sub
And the main one:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim Button2 As Button
Dim EditText1 As EditText
Dim panel2 As Panel
Private btnpanel1 As Button
Private btnpanel2 As Button
Private btnpanel3 As Button
Private btnpanel4 As Button
Private btnpanel5 As Button
Private btnpanel6 As Button
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("1")
Dim dv1, dv2, dv3, dv4, dv5 As DraggableView
dv1.Initialize(Activity, Button1)
dv2.Initialize(Activity, Button2)
dv3.Initialize(Activity, EditText1)
dv4.Initialize(Activity, panel2)
dv5.initialize(panel2, btnpanel1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Could somebody please help me ?
Thank you. And sorry for my bad english