Android Question Show title and Full screen enable / disable programmatically

ThePuiu

Active Member
Licensed User
Longtime User
I would like, if I can, to switch from code the full screen parameter of an activity. It is possible?
 

ilan

Expert
Licensed User
Longtime User
actually @klaus has already posted the code here: https://www.b4x.com/android/forum/t...screen-to-fullscreen-or-not.14767/post-108311


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.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Dim btn As Button
End Sub

Sub Activity_Create(FirstTime As Boolean) 'ignore
    btn.Initialize("btn")
    btn.Text = "Full Screen"
    btn.Tag = 0
   
    Activity.AddView(btn,50dip,50dip,100dip,100dip)
End Sub

Sub btn_Click
    If btn.Tag = 0 Then 'ignore
        btn.Tag = 1
        FullScreen(True,"Main")
        btn.Text = "Not Full Screen"
    Else
        btn.Tag = 0
        FullScreen(False,"Main")
        btn.Text = "Full Screen"
    End If
End Sub

Sub FullScreen(Active As Boolean, ActivityName As String)
    Dim obj1 As Reflector
    Dim i As Int

    i = 1024  'FLAG_FULLSCREEN
    obj1.Target = obj1.GetMostCurrent(ActivityName)
    obj1.Target = obj1.RunMethod("getWindow")
    If Active Then
        obj1.RunMethod2("addFlags",i,"java.lang.int")
    Else
        obj1.RunMethod2("clearFlags",i,"java.lang.int")
    End If
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub
 
Upvote 0
Top