title: Set status bar color dynamically in android
body: <p>How to set status bar color dynamically for an application, am using view pager while swiping (horizontally) status bar color and title bar and button should change the color . as per my code title and button color changing perfectly ,but the issue is status bar color taking next color from array list. how to fix that issue can anyone help me. here is my code</p>
  
  <pre><code> private int[] colors = new int[]{0xffffd200, 0xff37beb7, 0xff00ccff, 0xff8585c1, 0xfff2a03c, 0xff2a80b9, 0xfff15972,
          0xffe9776c, 0xff9dcc96,0xff76c069};
  
    if (Build.VERSION.SDK_INT &gt;= 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]);
      }
  </code></pre>