Skip to content

Support changing status bar color #38

Description

@pikaboo

The status bar has two colors
the background color and the text color

I want the background color to be transparent and thus take the color of whatever is behind it. And have the option of changing the foreground color from light to dark or dark to light (which is supported from android M and up)

current result:
image

desired result
image

The following in the launch screen helped me fix it:

public class Controller_LaunchScreen
        extends CyborgController {

    @Override
    protected void onCreate() {
        Window window = getActivity().getWindow();

// clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        View rootView = getRootView();
        int flags = rootView.getSystemUiVisibility();
//make the status bar text color dark
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        rootView.setSystemUiVisibility(flags);
// finally change the color
        window.setStatusBarColor(Color.TRANSPARENT);

        super.onCreate();
    }
    public Controller_LaunchScreen() {
        super(R.layout.controller_splash_screen);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions