Set status bar Farbe dynamisch in android

How to set status bar Farbe dynamisch für eine Anwendung, bin über view pager während swiping (horizontal) status bar Farbe und die Titelleiste und die Taste sollte sich die Farbe ändern . wie pro meine code Titel und button Farbe ändern perfekt ,aber das Problem ist die status bar Farbe nehmen nächste Farbe aus dem array-Liste. wie man das Problem beheben kann mir jemand helfen. hier ist mein code

 private int[] colors = new int[]{0xffffd200, 0xff37beb7, 0xff00ccff, 0xff8585c1, 0xfff2a03c, 0xff2a80b9, 0xfff15972,
        0xffe9776c, 0xff9dcc96,0xff76c069};

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = ((Activity) context).getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        int coloring = position % colors.length;
        int new_color = colors[coloring];
        window.setStatusBarColor(new_color);
        title_bar.setBackgroundColor(new_color);
        set_share.setBackgroundColor(new_color);

    }
    else{

        int color = position % colors.length;
        itemView.setBackgroundColor(colors[color]);
        title_bar.setBackgroundColor(colors[color]);
        set_share.setBackgroundColor(colors[color]);
    }

InformationsquelleAutor developer | 2015-12-02

Schreibe einen Kommentar