title: Android global layout listener called repeatedly in android
body: <p>Add global layout listener gets called even if there is no listener attached, It gets in a loop in this situation, how can I edit attributes without firing global layout listener in a loop ? thank you</p>
  
  <pre><code>final View getDecorView = activity.getWindow().getDecorView();
              getDecorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                  @Override
                  public void onGlobalLayout() {
  
                      if (Build.VERSION.SDK_INT &gt; 16) {
                          getDecorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                      } else {
                          getDecorView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                      }
  
                      final TextView textView3 = (TextView) decorView.findViewById(2131558456);
                      if (textView3 != null) {
                                  textView3.setText("updated");                      textView3.setBackgroundColor(Color.parseColor("#444444"));
                      }
  
                      getDecorView.getViewTreeObserver().addOnGlobalLayoutListener(this);
  
                  }
              });
  </code></pre>