B4J Question How do you check if User resizes to fullscreen?

Credo

Member
I want to hide an UI element in a page. How do I hide it or make it visible if its fullscreen or windowed?
The code below is one of my attempts.


B4X:
If Root.Width >(100) Then
        DelBtn.Visible=True
    End If
 
Last edited:

PaulMeuris

Well-Known Member
Licensed User
You can use the B4XPage_Resize subroutine in case you are using B4XPages.
Resize the form horizontally or vertically and you will see the button appearing or disappearing.
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Button1 As Button
    Private mainwidth As Double
    Private mainheight As Double
End Sub
Public Sub Initialize
    B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    mainwidth = Root.Width
    mainheight = Root.Height
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
    If Width < (mainwidth - (mainwidth / 4)) Or Height < (mainheight - (mainheight / 4)) Then
        Button1.Visible = False
    Else
        Button1.Visible = True
    End If
End Sub
Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub
 
Upvote 1
Top