Android Question rotate img slide buttons, etc ...

fgh3966

Active Member
Licensed User
I want to build an app and I would like that when the phone rotates the images also rotate.
Here is an sample from the source code.
How do I proceed ?
Thanks in advance

sample button slide img:
.......

Sub Globals
    
    Dim but1, but2, but3, but4, but5, but6, but7, but8, but9, but10 As ImageView
    Dim set1, set2, set3, set4, set5, set6, set7, set8, set9, set10=0 As Int    
End Sub

Sub Activity_Create(FirstTime As Boolean)
        Activity.LoadLayout("slide")
    
    but1.SetLayout(42%x, 5%y, 36%x, 5%y)
    but1.Bitmap = LoadBitmap(File.DirAssets, "but 2 OFF.png")
    but2.SetLayout(42%x, 20%y, 16%x, 5%y)    
    but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")

etc......
 

fgh3966

Active Member
Licensed User
Thank you for you reply

I load and declare xui library but there are error at "SetBitmap" or "Bitmap" if i write : but1.SetBitmap(xui.LoadBitmapResize(File.DirAssets,"but 2 OFF.png",but1.Width,but1.Height,True)) at line 35.

code :
setbitmap error:
#Region  Project Attributes
    #ApplicationLabel: Slide Button
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: true
#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.
    Private xui As XUI
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 but1, but2, but3, but4, but5, but6, but7, but8, but9, but10 As ImageView
    Dim set1, set2, set3, set4, set5, set6, set7, set8, set9, set10=0 As Int  
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("slide")
   
    but1.SetLayout(42%x, 5%y, 36%x, 5%y)
    but1.Bitmap = LoadBitmap(File.DirAssets, "but 2 OFF.png")
    but1.SetBitmap(xui.LoadBitmapResize(File.DirAssets,"but 2 OFF.png",but1.Width,but1.Height,True))
    but2.SetLayout(42%x, 20%y, 16%x, 5%y)  
    but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
    but3.SetLayout(42%x, 35%y, 16%x, 5%y)  
    but3.Bitmap = LoadBitmap(File.DirAssets, "but 76 OFF.png")
    but4.SetLayout(35%x, 50%y, 30%x, 7%y)  
    but4.Bitmap = LoadBitmap(File.DirAssets, "but i OFF.png")
    but5.SetLayout(32%x, 66%y, 35%x, 5%y)  
    but5.Bitmap = LoadBitmap(File.DirAssets, "but p OFF.png")
    but6.SetLayout(37%x, 80%y, 25%x, 15%y)  
    but6.Bitmap = LoadBitmap(File.DirAssets, "but q OFF.png")
   
End Sub

Sub but1_Click
set1=set1+1
If set1=1 Then
but1.Bitmap = LoadBitmap(File.DirAssets, "but 73 ON.png")
Else
set1=0
but1.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
End If
End Sub

Sub but2_Click
set2=set2+1
If set2=1 Then
but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 ON.png")
Else
set2=0
but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
End If  
End Sub
 
Upvote 0

fgh3966

Active Member
Licensed User
also i load B4Xcollection library and i try :

Private but1, but2, but3, but4, but5, but6, but7, but8, but9, but10 As B4XView

and it does not work
 
Upvote 0

fgh3966

Active Member
Licensed User
thank you

in this code you must swap line 19or line 27 as comentary

code for rotate image (slide button):
#Region  Project Attributes
    #ApplicationLabel: Slide Button
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: true
#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.
    Private xui As XUI
    'Private  but1, but2, but3, but4, but5, but6, but7, but8, but9, but10 As B4XView
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 but1, but2, but3, but4, but5, but6, but7, but8, but9, but10 As ImageView
    Dim set1, set2, set3, set4, set5, set6, set7, set8, set9, set10=0 As Int   
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("slide")
    
    but1.SetLayout(42%x, 5%y, 36%x, 5%y)
    'but1.Bitmap = LoadBitmap(File.DirAssets, "but 2 OFF.png")
    but1.SetBitmap(xui.LoadBitmapResize(File.DirAssets,"but 2 OFF.png",but1.Width,but1.Height,True))
    but2.SetLayout(42%x, 20%y, 16%x, 5%y)   
    but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
    but3.SetLayout(42%x, 35%y, 16%x, 5%y)   
    but3.Bitmap = LoadBitmap(File.DirAssets, "but 76 OFF.png")
    but4.SetLayout(35%x, 50%y, 30%x, 7%y)   
    but4.Bitmap = LoadBitmap(File.DirAssets, "but i OFF.png")
    but5.SetLayout(32%x, 66%y, 35%x, 5%y)   
    but5.Bitmap = LoadBitmap(File.DirAssets, "but p OFF.png")
    but6.SetLayout(37%x, 80%y, 25%x, 15%y)   
    but6.Bitmap = LoadBitmap(File.DirAssets, "but q OFF.png")
    
End Sub

Sub but1_Click
set1=set1+1
If set1=1 Then
but1.Bitmap = LoadBitmap(File.DirAssets, "but 73 ON.png")
Else
set1=0
but1.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
End If
End Sub

Sub but2_Click
set2=set2+1
If set2=1 Then
but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 ON.png")
Else
set2=0
but2.Bitmap = LoadBitmap(File.DirAssets, "but 73 OFF.png")
End If   
End Sub

Sub but3_Click
set3=set3+1
If set3=1 Then
but3.Bitmap = LoadBitmap(File.DirAssets, "but 76 ON.png")
Else
set3=0
but3.Bitmap = LoadBitmap(File.DirAssets, "but 76 OFF.png")
End If   
End Sub

Sub but4_Click
set4=set4+1
If set4=1 Then
but4.Bitmap = LoadBitmap(File.DirAssets, "but i ON.png")
Else
set4=0
but4.Bitmap = LoadBitmap(File.DirAssets, "but i OFF.png")
End If   
End Sub

Sub but5_Click
set5=set5+1
If set5=1 Then
but5.Bitmap = LoadBitmap(File.DirAssets, "but p ON.png")
Else
set5=0
but5.Bitmap = LoadBitmap(File.DirAssets, "but p OFF.png")
End If   
End Sub

Sub but6_Click
set6=set6+1
If set6=1 Then
but6.Bitmap = LoadBitmap(File.DirAssets, "but q ON.png")
Else
set6=0
but6.Bitmap = LoadBitmap(File.DirAssets, "but q OFF.png")
End If   
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Upvote 0
Top