B4J Question [BANano] Change Main background color (solved)

angel_

Well-Known Member
Licensed User
Longtime User
It is possible to change the background color (outside the MainHolder), now it has white color.

Captura.JPG
 
Solution
You will have to overrule the theme with CSS:

B4X:
#IF CSS
    .green-body {
        background-color: green !important;
    }
#End If
    
Dim body As BANanoElement
body.Initialize("body")
body.AddClass("green-body")

Alwaysbusy

angel_

Well-Known Member
Licensed User
Longtime User
It works fine from AppStart, would it be possible to change it while it's running?
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
You will have to overrule the theme with CSS:

B4X:
#IF CSS
    .green-body {
        background-color: green !important;
    }
#End If
   
Dim body As BANanoElement
body.Initialize("body")
body.AddClass("green-body")

Alwaysbusy

It works but when I want to switch back it doesn't, I've tried the following and it seems to work:

B4X:
Public Sub ChangeBackgroundColor
    Dim body As BANanoElement
    body.Initialize("body")

    If IsThemeLight Then
        If body.HasClass("theme-dark-body") Then
            body.RemoveClass(("theme-dark-body"))
        End If
        
        #IF CSS
            .theme-light-body {
                background-color: lightgray !important;
            }
        #End If
        
        body.AddClass("theme-light-body")
    Else
        If body.HasClass("theme-light-body") Then
            body.RemoveClass(("theme-light-body"))
        End If
        
        #IF CSS
            .theme-dark-body {
                background-color: black !important;
            }
        #End If
        
        body.AddClass("theme-dark-body")
    End If
End Sub
 
Upvote 0
Top