Amin Etesamian
Amin Etesamian

Reputation: 3699

kivy on android, change taskbar color

Is it possible to change the taskbar color when fullscreen is set to 0 in buildozer.spec file? I already tried changing Window.clearcolor value but hence taskbar is not part of Window when fullscreen is 0, taskbar color doesn't change. How does one do that?

Upvotes: 1

Views: 741

Answers (1)

Peter Badida
Peter Badida

Reputation: 12189

I believe this is the answer for Java, therefore (as inclement said) you need to use pyjnius to access the Java functions from Python and then wrap the code mentioned in the linked answer to something usable from Kivy.

Example (not tested):

from jnius import autoclass

WindowManager = autoclass('android.view.WindowManager')
R = autoclass('android.R')
activity = autoclass('<your.app.name>.PythonActivity').mActivity

window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color));

I think only these colors are available, but feel free to try other values. I've seen some issues with android.R importing in Java, so you might want to just use the raw values instead of fetching them from android.R module.

Upvotes: 1

Related Questions