You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #109491 from syntaxerror247/window-color
Android: Add method to set root window color at runtime
This commit is contained in:
@@ -260,16 +260,7 @@ class Godot private constructor(val context: Context) {
|
||||
useImmersive.set(true)
|
||||
newArgs.add(commandLine[i])
|
||||
} else if (commandLine[i] == "--background_color") {
|
||||
val colorStr = commandLine[i + 1]
|
||||
try {
|
||||
backgroundColor = colorStr.toColorInt()
|
||||
Log.d(TAG, "background color = $backgroundColor")
|
||||
} catch (e: java.lang.IllegalArgumentException) {
|
||||
Log.d(TAG, "Failed to parse background color: $colorStr")
|
||||
}
|
||||
runOnHostThread {
|
||||
getActivity()?.window?.decorView?.setBackgroundColor(backgroundColor)
|
||||
}
|
||||
setWindowColor(commandLine[i + 1])
|
||||
} else if (commandLine[i] == "--use_apk_expansion") {
|
||||
useApkExpansion = true
|
||||
} else if (hasExtra && commandLine[i] == "--apk_expansion_md5") {
|
||||
@@ -492,6 +483,21 @@ class Godot private constructor(val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fun setWindowColor(colorStr: String) {
|
||||
val color = try {
|
||||
colorStr.toColorInt()
|
||||
} catch (e: java.lang.IllegalArgumentException) {
|
||||
Log.w(TAG, "Failed to parse background color: $colorStr", e)
|
||||
return
|
||||
}
|
||||
val decorView = getActivity()?.window?.decorView ?: return
|
||||
runOnHostThread {
|
||||
decorView.setBackgroundColor(color)
|
||||
backgroundColor = color
|
||||
setSystemBarsAppearance()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to complete initialization of the view used by the engine for rendering.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user