title: Using View.getParent() in View's constructor
body: <p>Why doesn't this work?</p>
  
  <pre><code>private ScrollView findScrollParent(View v)
  {
  
      if(v==null)
      {
          return null;
      }
      else if(v instanceof ScrollView)
      {
          return (ScrollView) v;
      }
      else
      {
          return findScrollParent((View)v.getParent());
      }
  }
  
  CustomView(Context context, AttributeSet as)
  {
       super(context,as);
       ScrollView sv = findScrollParent(this);
  }
  </code></pre>
  
  <p>This is my xml file which is inflated:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_height="fill_parent"
       android:layout_width="fill_parent"&gt;
  &lt;ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
  
    &lt;LinearLayout android:layout_height="wrap_content"
          android:layout_width="wrap_content"&gt;
  
         &lt;com.myapp.CustomView android:layout_height="wrap_content"
                 android:layout_width="wrap_content"/&gt;
  
    &lt;/LinearLayout&gt;
  
  &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I want to have a reference to the scrollView in the custom View. My findScrollParent method finds the <code>LinearLayout</code> then returns null. I call this method in the <code>View v</code>'s constructor, is that the problem?</p>