title: Cannot get center of view inside dialog
body: <p>I have in essence two views inside a dialog. A <code>button</code>, and a <code>LinearLayout</code> which acts as a background. I'm trying to animate this <code>LinearLayout</code> with a <code>CircularReveal</code> from the center of the button so that it covers the whole dialog with a color.</p>
  
  <p>This is the xml that I use as a dialog:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;ScrollView android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@android:color/white"&gt;
  
          &lt;LinearLayout
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              ...
  
              &lt;com.dd.CircularProgressButton
                  android:id="@+id/sign_in_enter_button"
                  android:layout_gravity="bottom|center_horizontal"
                  android:layout_width="match_parent"
                  android:layout_height="42dp"
                  android:layout_marginRight="24dp"
                  android:layout_marginLeft="24dp"
                  android:textColor="@android:color/white"
                  android:textSize="15dp"
                  app:cpb_cornerRadius="1dp"
                  app:cpb_textIdle="@string/login_sign_in"
                  app:cpb_iconComplete="@drawable/ic_done_mini"
                  app:cpb_selectorIdle="@color/morph_button_idle_colors"
                  app:cpb_selectorComplete="@color/morph_button_complete_colors"
                  app:cpb_colorIndicator="@color/colorAccent"
                  app:cpb_colorIndicatorBackground="@android:color/transparent"
                  app:cpb_colorProgress="@android:color/transparent"/&gt;
  
              ...
  
          &lt;/LinearLayout&gt;
  
      &lt;/ScrollView&gt;
  
      &lt;!-- Background to be animated behind the CircularProgressButton --&gt;
      &lt;LinearLayout
          android:id="@+id/sign_in_dialog_background"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:visibility="invisible"
          android:layout_gravity="center"
          android:gravity="center"
          android:background="@color/colorAccent"&gt;
  
          ...
  
      &lt;/LinearLayout&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <hr>
  
  <p>To do this animation I've used this approach, which I've already used it in other places in my app and works perfectly:</p>
  
  <pre><code>final CircularProgressButton enterButton = (CircularProgressButton) parent.findViewById(R.id.sign_in_enter_button);
  
  ...
  
  // This is called inside a listener, so the button is already drawn.
  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP)
  {
      int enterButtonX = (enterButton.getLeft()
              + enterButton.getRight()) / 2;
  
      int enterButtonY = ((int) enterButton.getY()
              + enterButton.getHeight()) / 2;
  
      View background = mAlertDialogView.findViewById(R.id.sign_in_dialog_background);
  
      int radiusReveal = Math.max(background.getWidth()
              , background.getHeight());
  
      background.setVisibility(View.VISIBLE);
  
      Animator animator =
              android.view.ViewAnimationUtils.createCircularReveal(background
                      , enterButtonX
                      , enterButtonY
                      , 0
                      , radiusReveal);
  
      animator.setDuration(500);
      animator.setInterpolator(
              AnimationUtils.loadInterpolator(LoginUI.this, R.anim.accelerator_interpolator));
  
      animator.start();
  }
  </code></pre>
  
  <p>What's happening is that the coordinates are not even close to the button. In fact, the animation starts from the center of the dialog.</p>
  
  <p>Any idea of what I'm doing wrong?</p>
  
  <p>Thanks,</p>