title: Android <include/> works but ViewStub doesn't, why?
body: <p>I am using ViewStub inside FrameLayout so that I can inflate it with a tutorial view the first time the app is opened. </p>
  
  <p>My Activity.xml</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/fragment_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
     ...
  
     &lt;ViewStub
         android:id="@+id/introHolder"
         android:inflatedId="@+id/introHolder"
         android:layout="@layout/intro_landing1"
         android:layout_width="match_parent"
         android:layout_height="match_parent" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>the view I am inflating it is called <code>intro_landing1.xml</code> and it is a RelativeLayout.</p>
  
  <p>intro_landing1.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent" android:background="@color/opaqBlack30"
  android:id="@+id/introView1"
  android:tag="RelativeLayoutIntroViewTag"&gt;
  
  &lt;!--...--&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In my Activity onCreate I used two different approaches to inflate the ViewStub but neither of them work (I can't see the intro_landing1 view).</p>
  
  <p>1st approach - setting visibility:</p>
  
  <pre><code>if(!previouslyStarted){
     ((ViewStub) findViewById(R.id.introHolder)).setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>2nd approach - inflating the ViewStub:</p>
  
  <pre><code>ViewStub introStub =  (ViewStub) findViewById(R.id.introHolder);
  introStub.setLayoutResource(R.layout.intro_landing1);
  View inflatedView = introStub.inflate();
  </code></pre>
  
  <p>With the 2nd approach I logged the returned View (inflatedView) by doing inflatedView.getTag and it returned the intro_landing1 RelativeLayout's tag "RelativeLayoutIntroViewTag" so the view is actually returned but I dont see it.</p>
  
  <p>To make sure I positioned the ViewStub correctly in the view tree hierarchy I used the <code>&lt;include/&gt;</code> tag in the Activity.xml instead of the ViewStub like this:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/fragment_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
     ...
  
     &lt;!-- &lt;ViewStub
         android:id="@+id/introHolder"
         android:inflatedId="@+id/introHolder"
         android:layout="@layout/intro_landing1"
         android:layout_width="match_parent"
         android:layout_height="match_parent" /&gt;--&gt;
  
     &lt;include layout="@layout/intro_landing1"/&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>And this works.</p>
  
  <p>Why is it not showing the ViewStub after visibility change or inflation?</p>
  
  <p>Thanks!</p>