Hi Guys
I would like to share with you something that most of you maybe allready know but also if there are some people that still dont know that, it could be very helpfull for them.
There are lots of ways to animate something or scale, translate, resize ... views
i will show you a simple way to resize a panel without a timer only with a simple code (you can also
animate or do other stuff with this solution)
code:
regards,
I would like to share with you something that most of you maybe allready know but also if there are some people that still dont know that, it could be very helpfull for them.
There are lots of ways to animate something or scale, translate, resize ... views
i will show you a simple way to resize a panel without a timer only with a simple code (you can also
animate or do other stuff with this solution)
code:
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: false
#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 p As Panel
Dim b1 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("Layout1")
b1.Initialize ("b1") 'intialize button
b1.Text = "Click Me"
p.Initialize ("p") 'intialize panel
p.Color = Colors.White
Activity.AddView(p,10dip,10dip,200dip,100dip) 'add panel to actvity
Activity.AddView(b1,10dip,Activity.Height - 100dip,100dip,100dip) 'add button to actvity
End Sub
Sub b1_click
doanimation(p,200dip,200dip,100dip,100dip) 'start resize
End Sub
Sub Activity_Resume
End Sub
Sub doanimation(selp As Panel,maxw As Int, maxh As Int,minw As Int, minh As Int)
If selp.Height >= maxh Then
Do Until selp.Height <= minh
selp.Height = selp.Height - 5dip
DoEvents
Loop
Else
Do Until selp.Height >= maxh
selp.Height = selp.Height + 5dip
DoEvents
Loop
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
regards,
Attachments
Last edited: