title: Get positions of views in a dialog, relative to their parent
body: <p>What I want to do is, to draw a line from the edge of a button to a point on the screen...</p>
  
  <p>I'm using a dialog fragment for this... And all functions I tried always return the 0 point...</p>
  
  <p>I tried following:</p>
  
  <pre><code>@Override
  protected Dialog createDialog(Bundle savedInstanceState, FragmentActivity activity)
  {
      Dialog d = builder.create();
  
      View v = LayoutInflater.from(activity).inflate(R.layout.dialog, null);
      builder.setView(v);
  
      // custom view by my which draws simple lines between points...
      LineDrawView ldv = new LineDrawView(getActivity());
      ldv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  
      ((RelativeLayout)v).addView(ldv);
      Dialog d = builder.create();
  
      button = ((Button) v.findViewById(R.id.button));
      int[] pos = new int[2];
      button.getLocationInWindow(pos);
  
  //           tried following ways, all always return p(0, 0)
  //           button.getLocationInWindow(pos);
  //           Debugger.d("x: " + pos[0] + ", y: " + pos[1], "POS");
  
  //           button.getLocationOnScreen(pos);
  //           Debugger.d("x: " + pos[0] + ", y: " + pos[1], "POS");
  
  //           float x = button.getLeft();
  //           float y = button.getTop();
  //           Debugger.d("x: " + x + ", y: " + y, "POS");
  
  
      ldv.addLine(new Point(pos[0], pos[1]), new Point(pos[0] + 30, pos[1]), Color.RED);
      ldv.invalidate();
      return d;
  }
  </code></pre>
  
  <p>and it ALWAYS draws a line from the p(0, 0) to p(0, 30)...</p>
  
  <p><strong>How can I get the position of a button on the screen or preferable relative to it's parent view?</strong> I think, they layout is not finished yet, so I have to draw my lines somewhere later, but when and where?</p>