I want to dim the status bar from the service.

Asked 2 years ago, Updated 2 years ago, 38 views

I would like to always use setStatusBarColor() to darken the status bar in the background.

If you do so in the class that inherited the service, you will get an error in getWindow().

Please tell me how to use getWindow() for the service or setStatusBarColor() for the service.

android java

2022-09-30 18:43

1 Answers

By default, it is not possible.

First of all, Service is a component that does not have UI, so you cannot get = Window that is not attached to Window.

setStatusBarColor() is a relatively new API added from Android 5.0.This is intended for Lollipop and later applications to use the color of the action bar and status bar to brand the app.Prior to that, the design guidelines stated that the status bar color was fixed and branding was represented by placing the app icon on the action bar.

API's probably not available to interfere with color branding for other applications.

However, it is not entirely possible.

WindowManager can also be retrieved from the service, so I think you can make it look like that by overlapping any view there.The specification on top of the status bar depends on the SDK version, but considering that it is 5.0 or later with setStatusBarColor(), LayoutParams and TYPE_STATUS_BAR_PANEL.

This is also a risky measure, so I'll leave it to you.


2022-09-30 18:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.