title: Getting real color of a ViewGroup and compare with resource color
body: <p>I am trying to get color of a ViewGroup and trying to compare with a resource color. </p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  android:layout_width="match_parent"
                  android:id="@+id/mainLayout"
                  android:background="@color/colorPrimary"
                  android:layout_height="match_parent"
                  &gt;
  </code></pre>
  
  <p>In my code i am doing this.</p>
  
  <pre><code>ViewGroup mainLayout = (ViewGroup) findViewById(R.id.mainLayout);
          ColorDrawable viewColor = (ColorDrawable) mainLayout.getBackground();
          if (viewColor != null)
          {
              int colorId = viewColor.getColor(); // i get -6371612
              int mainColor = getResources().getColor(R.color.colorPrimary); // i get -65536
              if (colorId == mainColor)
              {
                  mainLayout.setBackgroundColor(Color.RED);
              }
          }
  </code></pre>
  
  <p>The colorId and mainColor are not same. What am i missing? shouldn't they be same?</p>