Reputation: 951
I am working on an android qt app. I want to change the color of android status bar to be same as that of my application background color. Currently whatever be the color of my application the status bar remains black.Is there any way by which i can make the color of status bar same as my application.I am not Using Java In my application.I want to do this by making changes only to the androidManifest.xml file. Is this possible.
Upvotes: 0
Views: 1043
Reputation: 31
Here's a test project that does that. The important code snippet is:
QtAndroid::runOnAndroidThread([=]() {
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
window.callMethod<void>("addFlags", "(I)V", FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.callMethod<void>("clearFlags", "(I)V", FLAG_TRANSLUCENT_STATUS);
window.callMethod<void>("setStatusBarColor", "(I)V", color.rgba());
});
See bug report: https://bugreports.qt.io/browse/QTBUG-51196
Upvotes: 0
Reputation: 304
You only need to add this in your code:
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
Upvotes: 0
Reputation: 442
To change status bar color use setStatusBarColor(int color). According javadoc, we also need set some flags on Window.
Working snippet of code:
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(activity.getResources().getColor(R.color.example_color));
Keep in mind, according Material Design guidelines, status bar color and action bar color should be different:
ActionBar should use primary 500 color
StatusBar should use primary 700 color.
Resource:(How to change status bar color to match app in Lollipop? [Android])
Upvotes: 1